node.js - PM2 - 语法错误 : Block-scoped declarations not yet supported outside strict mode

标签 node.js ubuntu server coffeescript pm2

我目前正在 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 启动哪个脚本,似乎都会发生此错误,因此一定有某些内容配置不正确..

我不知道这是否重要,但我尝试运行的脚本需要 Node v4.9.1,所以我使用 NVM 来使用该版本,在我看来,它正在尝试使用相同的 Node 版本运行 pm2不知何故?

非常感谢您的任何意见,因为我已经在这个问题上坚持了太久了!!

最佳答案

我在 Node 版本 4.x 上遇到了同样的问题,

降级 pm2 并成功。

npm uninstall -g pm2
npm install -g <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72021f4032415c425c46" rel="noreferrer noopener nofollow">[email protected]</a>

关于node.js - PM2 - 语法错误 : Block-scoped declarations not yet supported outside strict mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55842552/

相关文章:

node.js - Node.JS 中的简单 DNS 服务器? (主要/权威 DNS 服务器)(也许是 ndns?)

mysql - 无法设置远程连接 MYSQL Ubuntu

php - WampServer 3.0.0 AH01630 : client denied by server configuration:

swift - 在使用 Bright Futures 的 Swift Express 中,如何处理异步操作?

javascript - 如何设置 Firebase 数据库规则以不允许删除或更新子项?

javascript - 我在node.js中使用promise的错误在哪里

node.js - KrakenJS 禁用 session

python - PIP 安装 PIL python2.7 ubuntu 14.04.1

eclipse - Nutch 无法获取 UTF-8 字符

c - C 中的服务器-客户端 : Weird behaviour when sending bytes