How to stop running npm process on the terminal shell

Unlike with starting a npm process where you need to run the npm start or npm run serve command, stopping a running npm process doesn’t require a command.

You can stop any running npm process with CTRL + C (Windows/Linux/Mac)

For example, suppose you have a running Vue local server as follows:

$ npm run serve
 DONE  Compiled successfully
  App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.1.5:8080/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

You need to select the running shell window, then press CTRL + C to stop the process.

You should see a new line available in your shell, indicating that you can run another command from it:

 DONE  Compiled successfully


  App running at:
  - Local:   http://localhost:8080/
  - Network: http://192.168.1.5:8080/

  Note that the development build is not optimized.
  To create a production build, run npm run build.

# CTRL + C
nsebhastian@fn-mac ~/Desktop/DEV/v-app $

Alternatively, you can close the shell window to stop the running process immediately.

This can be useful when the running process is lagging and pressing CTRL + C isn’t working.

The same method will work no matter what project you are running (Vue, React, Express, etc.)

People new to npm-based projects usually thought they need to create a stop script in the scripts object:

{
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "stop": "put something here"
  }
}

But while you can define a stop script to run with the npm stop command, that command doesn’t have any special meaning in npm.

It’s just another command you can run using npm, but it doesn’t stop the running server just because the name is npm stop.

To stop a running npm process, press CTRL + C or close the shell window.

Here’s a short video showing the keystrokes:

And that’s how you stop a running npm process on the terminal.

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.