是否有一种方法让pm2运行npm启动脚本,或者你只需要运行pm2 start app.js
所以在发展中
npm start
然后在使用pm2的生产中,你会运行这样的程序
pm2 start 'npm start'
有一种等效的方法可以永远做到这一点:
forever start -c "npm start" ./
是否有一种方法让pm2运行npm启动脚本,或者你只需要运行pm2 start app.js
所以在发展中
npm start
然后在使用pm2的生产中,你会运行这样的程序
pm2 start 'npm start'
有一种等效的方法可以永远做到这一点:
forever start -c "npm start" ./
当前回答
pm2 start ./bin/www
可以运行
如果你想部署多个服务器 你可以这样做。而不是pm2启动NPM——启动
其他回答
如果你通过节点模块而不是全局使用PM2,你需要设置interpreter: 'none'以使上述解决方案工作。相关文档在这里。
在ecosystem.config.js:
apps: [
{
name: 'myApp',
script: 'yarn',
args: 'start',
interpreter: 'none',
},
],
我在下面写了shell脚本(名为start.sh)。 因为我的包裹。Json有预启动选项。 我想运行npm start。
#!/bin/bash
cd /path/to/project
npm start
然后,通过pm2启动start.sh。
pm2 start start.sh --name appNameYouLike
Pm2启动NPM——name" custom_pm2_name"——运行prod
"scripts": {
"prod": "nodemon --exec babel-node ./src/index.js"
}
当其他人没有的时候,这对我有用
是的,我们可以,现在pm2支持npm start,——name为物种应用程序名称。
pm2 start npm --name "app" -- start
您可以将目录更改为项目
cd /my-project
然后运行
pm2 start "npm run start" \\ run npm script from your package.json
点击这里阅读更多