是否有一种方法让pm2运行npm启动脚本,或者你只需要运行pm2 start app.js

所以在发展中

npm start

然后在使用pm2的生产中,你会运行这样的程序

pm2 start 'npm start'

有一种等效的方法可以永远做到这一点:

forever start -c "npm start" ./

当前回答

开始前别忘了留出空间

pm2 start npm --[space]start

所以正确的命令是:

pm2 start npm -- start

其他回答

是的,我们可以,现在pm2支持npm start,——name为物种应用程序名称。

pm2 start npm --name "app" -- start

现在,你可以用after:

pm2 start npm -- start

关注https://github.com/Unitech/pm2/issues/1317#issuecomment-220955319

它在CentOS 7上运行良好

PM2版本4.2.1

让我们举两个例子:

1. npm start //server.js

pm2 start "npm -- start" --name myMainFile

2. NPM运行main //main.js

pm2 start "npm -- run main" --name myMainFile
pm2 start ./bin/www

可以运行

如果你想部署多个服务器 你可以这样做。而不是pm2启动NPM——启动

您可以将目录更改为项目

cd /my-project

然后运行

pm2 start "npm run start" \\ run npm script from your package.json

点击这里阅读更多