Home > Software design >  Kill process started with NPM (pm2)
Kill process started with NPM (pm2)

Time:12-16

I installed pm2 with NPM without the global flag. Then I started de index scrpit with "npm start" thath declared on package.json as

"start": "pm2 start index.js"

How con I stop it?

CodePudding user response:

You can access locally-installed pm2 with npx:

$ npx pm2 list
$ npx stop 0 # first app will have ID=0

But in general, I would manage it by attaching a name to the app. Let's edit your package.json:

"start": "pm2 start index.js --name my-app"
"stop": "pm2 stop my-app",
"logs": "pm2 logs my-app"

And then:

$ npm run start
$ npm run logs
$ npm run stop

CodePudding user response:

Oh, was easy as installing it globally

npm install pm2 -g

and then kill the process. I thought it will be a "different" thing

  • Related