How stop after running react-scripts start?

2020-05-26 09:25发布

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?

5条回答
老娘就宠你
2楼-- · 2020-05-26 10:02

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

taskkill -F -IM node.exe

Just type the code in the terminal

查看更多
相关推荐>>
3楼-- · 2020-05-26 10:04

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.

查看更多
Viruses.
4楼-- · 2020-05-26 10:06

Add this in your package.json:

"stop": "taskkill -F -IM node.exe"
查看更多
何必那么认真
5楼-- · 2020-05-26 10:19

Hit your keyboard shortcut for stopping terminal commands (usually Ctrl+C or Ctrl+Q)

Or, if you don't have input access to the process, identify its PID and kill it :

On Windows :

C:\>Taskkill /PID <PID> /F

On Linux :

$>kill -SIGTERM <PID>
查看更多
Animai°情兽
6楼-- · 2020-05-26 10:20

Hitting Ctrl + C will stop the running app after you provide an answer as Y as it asks; No need to close your terminal.

查看更多
登录 后发表回答