新aws机器部署了老nodejs项目,使用pm2 start config.js启动,提示:
[PM2] Spawning PM2 daemon with pm2_home=/home/ec2-user/.pm2
没有错误提示,pm2 log / pm2 status都看不到信息, nodejs项目也没启动。
其实可以通过查看~/.pm2/pm2.log 文件获取真正错误信息:
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/nodejs/lib/node_modules/pm2/lib/Watcher.js:6:16)
/home/ec2-user/.pm2/pm2.log (END)
/usr/local/lib/nodejs/lib/node_modules/pm2/node_modules/chokidar/index.js:151
async remove(item) {
^^^^^^
以为是chokidar的版本太新了,切换到[email protected],再运行pm2 start config.js还是上面的错误。 由于nodejs使用的是比较老的6.15.1的版本,想到会不会是pm2的版本太新了,因此,将pm2由4.1.2降为3.2.3
npm insall -g [email protected]
安装完后果然OK了, 记录下希望对其他也碰到此类问题的有一些帮助。
Sorry, the comment form is closed at this time.