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" ./
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).
So npm start runs the node script that is listed under start in the package. json.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With