2

I tried using this question's answer (Run a custom npm script with PM2), but it's not working for me. I have a folder called 'frontend' and I want to start the 'dev' script inside it, but it keeps starting the default 'start' script. Some of my tries:

  • pm2 start frontend -- run dev --
  • pm2 start frontend -- run dev
  • pm2 start npm --name=frontend -- dev
  • pm2 start npm --name=frontend -- run dev
Natixco
  • 651
  • 5
  • 20

1 Answers1

8

The order is different :-)

what -- does is, it pipes the arguments righthand of -- to the left hand.

First you need to go to that frontend folder where(or wherever) package.json is located then,

pm2 start npm -- run dev

pm2 start starts the process.
npm here means you want to start the npm command.
-- run dev means run dev is piped to npm. So basically you are running, pm2 start (npm run dev)

If you want to add process name add it BEFORE npm:

pm2 start --name="MyPRocess" npm -- run dev
Aritra Chakraborty
  • 12,123
  • 3
  • 26
  • 35
  • Thank you, I'll keep that in mind! Actually I needed this to run 'ng serve', I tried now like: pm2 start ng -- run serve but this didn't work. Anyway I ended up just cding into the folder and running 'ng serve'. I only need this just for development, so that's not a big deal. – Natixco Sep 08 '19 at 19:35