steven iseki steven iseki - 7 months ago 64
Node.js Question

Can pm2 run an 'npm start' script

Is there a way for pm2 to run an npm start script or do you just have to run

pm2 start app.js

So in development

npm start

Then in production with pm2 you would run something like

pm2 start 'npm start'

There is an equivalent way to do this in forever

forever start -c "npm start" ./


Yes. Use pm2 start npm --no-automation --name {app name} -- run {script name}. It works. The --no-automation flag is there because without it PM2 will not restart your app when it crashes.