Categories
JavaScript Answers

How to stop Node.js Express app that’s started with ‘npm start’?

Spread the love

To stop Node.js Express app that’s started with ‘npm start’, we use the pkill command.

For instance, in package.json, we add

{
  //...
  "scripts": {
    "start": "app.js",
    "stop": "pkill --signal SIGINT myApp"
  }
  //...
}

to add a stop script that runs pkill with the SIGINT signal to stop the myApp app.

We use myApp to kill app.js since we set process.title to 'myApp' in app.js.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *