pm2 npm start code example

Example 1: installing pm2 on linux

$ sudo npm i -g pm2

Example 2: install pm2

npm install pm2 -g

Example 3: pm2 to start npm run dev

pm2 start "npm run dev" --name myAppName

Example 4: pm2 start npm start

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

Example 5: pm2 node start

# only start will make it
pm2 start app.js

Example 6: how to run script command in pm2

pm2 start npm --name "myApp" -- run "start:test"

pm2 start npm --name "myApp" -- run "start:staging"

pm2 start npm --name "myApp" -- run "start:production"