PM2 - SyntaxError:在严格模式之外尚不支持块范围的声明 [英] PM2 - SyntaxError: Block-scoped declarations not yet supported outside strict mode

查看:49
本文介绍了PM2 - SyntaxError:在严格模式之外尚不支持块范围的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 Ubuntu 服务器上安装 NodeJS 服务.该应用程序是用 coffeescript 编写的,它自己运行良好.这是我设置项目的方式:

I'm currently installing a NodeJS service on an Ubuntu server. The application is written in coffeescript and runs fine on it's own. This is how I setup the project:

cd ~/test-project
nvm use v4.9.1
npm install
pm2 start index.js

但是,当我尝试使用 pm2 启动它时,出现以下错误:

However when I try to start it using pm2 i get the error below:

/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 启动什么脚本,似乎都会发生这个错误,所以一定有一些配置不正确..

And after doing some testing it seems that this error occurs no matter what script I start with pm2 so there must be something that isn't configured correctly..

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

I don't know if it matters but the script I am trying to run needs node v4.9.1 so I am using NVM to use that version, it seems to me that it is trying to run pm2 with that same node version somehow?

非常感谢任何输入,因为我已经坚持了太久了!!

Any input is greatly appreciated as I've been stuck on this for way too long!!

推荐答案

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

I had the same issue on node version 4.x,

降级 pm2 并且它工作了.

Downgraded the pm2 and it worked.

npm uninstall -g pm2
npm install -g pm2@3.0.4

这篇关于PM2 - SyntaxError:在严格模式之外尚不支持块范围的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆