我目前正在 Ubuntu 服务器上安装 NodeJS 服务。该应用程序是用 CoffeeScript 编写的,并且可以自行运行良好。这就是我设置项目的方式:
cd ~/test-project
nvm use v4.9.1
npm install
pm2 start index.js
但是,当我尝试使用 pm2 启动它时,出现以下错误:
/usr/local/lib/node_modules/pm2/node_modules/needle/node_modules/debug/src/node.js:132
let val = process.env[key];
^^^
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 Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/needle/node_modules/debug/src/index.js:9:19)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
经过一些测试后,无论我用 pm2 启动什么脚本,似乎都会发生此错误,所以一定有一些配置不正确的东西。
我不知道这是否重要,但我尝试运行的脚本需要节点 v4.9.1,所以我使用 NVM 来使用该版本,在我看来,它试图以某种方式使用相同的节点版本运行 pm2 ?
任何意见都非常感谢,因为我已经坚持这个太久了!
我在节点版本 4.x 上遇到了同样的问题,
降级了pm2,它起作用了。
npm uninstall -g pm2
npm install -g [email protected] /cdn-cgi/l/email-protection
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)