在 Mac 上停止 node.js 进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18631813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stopping node.js process on Mac
提问by user2516371
I have a node.jsapplication that uses some socket ports. Sometimes, when I exit the application with Ctrl + C, some kind of node process is left running, still allocating the socket ports. Thus, I cannot restart my application, since it fails to open those ports. When I look the situation with ps, I get the following response:
我有一个node.js使用一些套接字端口的应用程序。有时,当我使用 退出应用程序时Ctrl + C,某种节点进程仍在运行,仍在分配套接字端口。因此,我无法重新启动我的应用程序,因为它无法打开这些端口。当我查看情况时ps,我得到以下响应:
$ ps
PID TTY TIME CMD
40454 ttys000 0:00.11 -bash
41643 ttys001 0:00.00 (node)
41741 ttys001 0:00.00 (node)
Trying kill -9 41643doesn't kill the process. Is it a some kind of unkillable zombie? How can I get rid of those (node)-things blocking my tcpports?
尝试kill -9 41643不会终止进程。它是某种无法杀死的僵尸吗?我怎样才能摆脱那些阻塞我tcp端口的(节点)东西?
回答by Krasimir
I'm not a MAC user, but here is what I use to kill all the available node processes (under linux):
我不是 MAC 用户,但这是我用来杀死所有可用节点进程的方法(在 linux 下):
sudo killall -9 node
回答by Sal
On macOS, it's simply:
在 macOS 上,它很简单:
sudo killall -9 node
For a lot of the times, sudois overkill, but in your case, it looks like you might want to try sudo.
很多时候,这sudo是矫枉过正,但就您而言,看起来您可能想尝试sudo.

