steven iseki steven iseki -5 years ago 515
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" ./

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download