我已经构建了React Apps:
npm run build
并安装了全局服务包:
npm install -g serve
并运行它:
serve -s build
如何阻止它?
我已尝试serve help
,但它没有显示任何停止选项
选项:
-a, --auth Serve behind basic auth -c, --cache Time in milliseconds for caching files in the browser -n, --clipless Don't copy address to clipboard (disabled by default) -C, --cors Setup * CORS headers to allow requests from any origin (disabled by default) -h, --help Output usage information -i, --ignore Files and directories to ignore -o, --open Open local address in browser (disabled by default) -p, --port <n> Port to listen on (defaults to 5000) -S, --silent Don't log anything to the console -s, --single Serve single page applications (sets `-c` to 1 day) -u, --unzipped Disable GZIP compression -v, --version Output the version number
答案 0 :(得分:6)
您可以像控制其他任何流程一样在控制台上停止该过程:Ctrl + c
。
请参阅https://superuser.com/questions/103909/how-to-stop-a-process-in-terminal
答案 1 :(得分:4)
我有同样的问题使用服务来提供我的反应应用程序的生产版本(从create-react-app构建)。
我终于可以通过在我的文件系统上的其他地方再次使用服务来杀死它(比如我的主目录,然后用> cd ~
> serve
杀死它。
您可以执行以下操作来终止serve提供的响应应用:
Ctrl + c
然后使用{{1}}
然后转到http://localhost:5000确认没有投放任何内容。
答案 2 :(得分:3)
您可以使用以下命令:
$ killall -9 node
答案 3 :(得分:0)
在使用服务进行生产构建时,我遇到了同样的问题。我终止了端口,而不是停止服务。
sudo fuser -k <portno>/tcp
答案 4 :(得分:0)
只需关闭运行npm的“本地控制台”