Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" ./ 
like image 304
svnm Avatar asked Jul 23 '15 06:07

svnm


People also ask

How do I run npm run Dev with pm2?

The following works for me. You can also specify the app name with --name argument, like this: pm2 start "npm run dev" --name myAppName Then you can see logs by pm2 logs myAppName Also, please don't use sudo until it's really necessary (in most cases, pm2 can work fine without sudo).

What script does npm start run?

So npm start runs the node script that is listed under start in the package. json.


1 Answers

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 
like image 94
Dhaval Chauhan Avatar answered Sep 23 '22 02:09

Dhaval Chauhan