如何停止 npm 服务
How to stop npm serve
我构建了 React 应用程序:
npm run build
并安装了全局服务包:
npm install -g serve
和运行它:
serve -s build
我该如何阻止它?
我试过了serve help
但是没有显示任何停止选项
Options:
-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
您可以像任何其他进程一样在控制台上停止该进程:Ctrl + c
。
见https://superuser.com/questions/103909/how-to-stop-a-process-in-terminal
我在使用 serve 为我的 React 应用程序(从 create-react-app 构建)的生产构建提供服务时遇到了同样的问题。
我终于能够通过在我的文件系统的其他地方再次使用服务来杀死它(比如我的主目录,然后用以下命令杀死它:Ctrl + c
。
你可以做这样的事情来杀死由 serve:
服务的你的 React 应用程序
> cd ~
> serve
然后使用Ctrl + c
然后转到 http://localhost:5000 以确认未提供任何服务。
我在使用 serve 进行生产构建时遇到了同样的问题。我终止了端口而不是停止服务。
sudo fuser -k <portno>/tcp
只需关闭您 运行 您的 npm
所在的“本地控制台”
您可以使用以下命令:
$ killall -9 node
我构建了 React 应用程序:
npm run build
并安装了全局服务包:
npm install -g serve
和运行它:
serve -s build
我该如何阻止它?
我试过了serve help
但是没有显示任何停止选项
Options:
-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
您可以像任何其他进程一样在控制台上停止该进程:Ctrl + c
。
见https://superuser.com/questions/103909/how-to-stop-a-process-in-terminal
我在使用 serve 为我的 React 应用程序(从 create-react-app 构建)的生产构建提供服务时遇到了同样的问题。
我终于能够通过在我的文件系统的其他地方再次使用服务来杀死它(比如我的主目录,然后用以下命令杀死它:Ctrl + c
。
你可以做这样的事情来杀死由 serve:
服务的你的 React 应用程序> cd ~
> serve
然后使用Ctrl + c
然后转到 http://localhost:5000 以确认未提供任何服务。
我在使用 serve 进行生产构建时遇到了同样的问题。我终止了端口而不是停止服务。
sudo fuser -k <portno>/tcp
只需关闭您 运行 您的 npm
所在的“本地控制台”您可以使用以下命令:
$ killall -9 node