Can pm2 run an 'npm start' script
Those who are using a configuration script like a .json
file to run the pm2 process can use npm start
or any other script like this -
my-app-pm2.json
{ "apps": [ { "name": "my-app", "script": "npm", "args" : "start" } ]}
Then simply -
pm2 start my-app-pm2.json
Edit - To handle the use case when you have this configuration script in a parent directory and want to launch an app in the sub-directory then use the cwd
attribute.
Assuming our app is in the sub-directory nested-app
relative to this configuration file then -
{ "apps": [ { "name": "my-nested-app", "cwd": "./nested-app", "script": "npm", "args": "start" } ]}
More detail here.