运行react-scripts后如何停止?

use*_*293 7 javascript node.js reactjs pkill react-scripts

我用npm start来启动一个React应用程序,其中package.json中定义了start:

{
  "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"
  }
}
Run Code Online (Sandbox Code Playgroud)

我现在想停止它,而不关闭终端。我怎么做?

尝试过:npm stop testrectapp,但是会抛出错误,需要脚本

然后尝试:使用脚本“ stop”运行npm run stop:“ pkill --signal SIGINT testreactapp”抛出错误“ pkill无法识别为命令”

编辑:在bash中运行ps显示: 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> 那里没有看到该应用程序?

rhe*_*ser 8

将此添加到您的package.json中:

"stop": "taskkill -F -IM node.exe"
Run Code Online (Sandbox Code Playgroud)


Sat*_*tel 7

Ctrl + C在您Y按要求提供答案后,点击将停止正在运行的应用;无需关闭终端。

  • CTRL+C 不会询问任何内容,并且始终让进程保持运行状态,直到终端关闭为止,至少在 ZSH 中是这样。 (3认同)
  • 同样在这里。我每次都需要关闭/重新打开我的终端。这只是过去一两个月才出现的问题。 (2认同)

小智 7

我也有同样的问题。我用这段代码来阻止它

taskkill -F -IM node.exe
Run Code Online (Sandbox Code Playgroud)

只需在终端中输入代码


bru*_*obi 7

要确保该过程已完成,只需键入命令:

$ killall -9 node
Run Code Online (Sandbox Code Playgroud)

将杀死名为“node”的所有进程。-9使用内核来杀死进程,而不是进程本身。

请参阅联机帮助页


Ant*_*ray 5

点击键盘快捷键以停止终端命令(通常是Ctrl + C或Ctrl + Q)

或者,如果您没有对该进程的输入访问权限,请识别其PID并杀死它:

在Windows上:

C:\>Taskkill /PID <PID> /F
Run Code Online (Sandbox Code Playgroud)

在Linux上:

$>kill -SIGTERM <PID>
Run Code Online (Sandbox Code Playgroud)

  • 我在 cygwin bash 终端的 Windows 机器上工作。我现在尝试 Ctrl-C 但这不起作用。 (2认同)