问题描述
我通过以下方式启动了一个React应用npm开始在package.json中定义开始:
I started a React app withnpm startwith 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?
已尝试:npm停止testrectapp但这会引发需要脚本的错误
Tried:npm stop testrectappbut that throws error that it needs a script
然后尝试:npm run stop with脚本"stop":"pkill --signal SIGINT testreactapp"引发错误无法将pkill识别为命令"
Then tried:npm run stop with script "stop": "pkill --signal SIGINT testreactapp"that throws error 'pkill is not recognized as a command'
在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>
在那儿看不到应用程序吗?
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?
推荐答案
使用键盘快捷键停止终端命令(通常是Ctrl + C或Ctrl + Q)
Hit your keyboard shortcut for stopping terminal commands (usually Ctrl+C or Ctrl+Q)
或者,如果您无权访问该进程,请确定其PID并杀死它:
Or, if you don't have input access to the process, identify its PID and kill it :
在Windows上:
C:\>Taskkill /PID <PID> /F
在Linux上:
$>kill -SIGTERM <PID>
这篇关于运行react-scripts后如何停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!