How stop after running react-scripts start?

Viewed 102993

I started a React app with npm start with start defined in package.json:

{
  "name": "testreactapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-scripts": "1.0.10"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

I want to stop it now, without closing the terminal. How do I do that?

Tried: npm stop testrectapp but that throws error that it needs a script

Then tried: npm run stop with script "stop": "pkill --signal SIGINT testreactapp" that throws error 'pkill is not recognized as a command'

Edit

Running ps in bash shows:

      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     6652       1    6652       6652  ?         197612 19:52:49 /usr/bin/mintty
     1092       1    1092       1092  ?         197612   Jul 25 /usr/bin/mintty
    11092    6652   11092      10060  pty1      197612 19:52:49 /usr/bin/bash
    13868    1092   13868        992  pty0      197612   Jul 25 /usr/bin/bash
    11428   13868   11428      17340  pty0      197612 12:48:27 /usr/bin/ps
    11672    1092    1092      11672  ?         197612   Jul 25 /usr/bin/mintty <defunct>

Don't see the app there?

10 Answers

I had same issue too. I used this code to stop it

taskkill -F -IM node.exe

Just type the code in the terminal

To make sure the process it finished just type the command:

$ killall -9 node

Will kill all processes by with the name "node". -9 to use kernel for killing the process, instead of process itself.

See the manpage

If you're using Git Bash you might get an invalid arguments error. You have to use the following syntax.

To check which PID to kill:

netstat -aon

Look for 127.0.0.1:3000 under Local Address and note the PID

To kill the process:

taskkill -f //PID ####

where #### is the PID from above.

I am having the same problem on Mac with a terminal started in VS code.

CTRL C kills the node server however a vscode process remains attached to the port afterwards and prevents restarting on the same port.

The following workaround works for me on Mac

npx kill-port 3000

You can call this from another terminal and it should kill the node server and any other related vscode processes attached to the port and allow you to restart the server on the same port.

You can also add a script in package.json:

"stop": "npx kill-port 3000"

Then call yarn stop to stop your server

Simply use Ctrl + c and it will stop the server, simple.

  1. Open Task manager (Task Bar Righ click/press Ctrl + Alt + Delete)

  2. Go on to the Processes tab

  3. Find the Node. js: Server-side JavaScript

  4. End the task.

working in macOS but cant work ctrl + c

  1. open a terminal in vs code

  2. right-click on the terminal OR click on right top zsh-appname

  3. click last one kill terminal

Related