Can pm2 run an 'npm start' script

svnm picture svnm · Jul 23, 2015 · Viewed 198.8k times · Source

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

Dhaval Chauhan picture Dhaval Chauhan · Jun 12, 2016

PM2 now supports npm start:

pm2 start npm -- start

To assign a name to the PM2 process, use the --name option:

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