Raspberry and nodered-nodejs-npm语法错误

问题描述 投票:1回答:1

我正在尝试为我的覆盆子pi3在nodered中安装一个传感器节点。该传感器是空气质量传感器SDS011,安装命令如下:

npm install node-red-contrib-sds011

那么,我认为这是一些更新的问题,实际上是命令

node -v

给我“ v4.4.5”作为答案。

问题是,当我尝试使用一些npm命令时,如上面的传感器命令,我总是会得到此错误作为答案:

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

此外,如果我尝试启动node.red控制台,则会出现类似的错误:

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.

一些建议?

非常感谢。

node.js npm node-red
1个回答
0
投票

NodeJS v4.4.5的版本非常老,并且完全不受支持(它于2018年4月停产。

Node-RED当前至少需要NodeJS版本8.x(https://nodered.org/docs/faq/node-versions

您需要升级您的系统,我建议您使用从here链接到的脚本,因为它将升级到最新的NodeJS和Node-RED。


0
投票

thx,可能我运行了安装v4.4.5的旧命令

无论如何,使用命令听起来很奇怪

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

节点版本未更新。

© www.soinside.com 2019 - 2024. All rights reserved.