I'm trying to install a sensor node in nodered for my raspberry pi3. The sensor is the air quality sensor SDS011, and the command to install it is the following:
npm install node-red-contrib-sds011
allright then, I think that is a problem with some updates, actually the command
node -v
gives me "v4.4.5" as answer.
The problem is that when i try to use some npm commands, as the one above for the sensor, i'll get always this error as answer:
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Furthermore, if i try to launch the node.red console, a similar error appears:
Starting as a systemd service.
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/fs/index.js:93
exports.write = function (fd, buffer, ...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/ lib/index.js:6:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/fs/index.js:93
exports.write = function (fd, buffer, ...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/ lib/index.js:6:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 2.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/fs/index.js:93
exports.write = function (fd, buffer, ...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/ lib/index.js:6:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 3.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/fs/index.js:93
exports.write = function (fd, buffer, ...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/ lib/index.js:6:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 4.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/fs/index.js:93
exports.write = function (fd, buffer, ...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/index.js:6:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 5.
Stopped Node-RED graphical event wiring tool.
nodered.service: Start request repeated too quickly.
nodered.service: Failed with result 'exit-code'.
Failed to start Node-RED graphical event wiring tool.
some suggestions?
many thanks.
NodeJS v4.4.5 is VERY old and totally out of support (it went EOL in April 2018).
Node-RED currently requires at least NodeJS version 8.x (https://nodered.org/docs/faq/node-versions)
You will need to upgrade your system, I suggest you use the script linked to from here as it will upgrade to the latest NodeJS and Node-RED.