如何杀死Node.js上的开放进程? [英] How to kill an open process on node.js?
问题描述
我试图在Sublime上为Node.js建立一个构建系统,所以我可以按F7键在打开的文件上调用"node".问题在于该过程将永远开放,因此,第二次使用F7时,我会获得一个加载项.
I'm trying to set up a build-system for Node.js on sublime, so I can press F7 to call "node" on the openned file. The problem is that the process is then open forever, so, the second time I use F7 I get an add-in-use.
有没有办法可以杀死来自node.js的打开的"node.exe"进程?
Is there a way I can kill the openned "node.exe" process from node.js?
推荐答案
使用以下命令集来标识在给定端口上运行的进程并从命令行终止该进程
Use the following set of commands to identify the process running on a given port and to termiate it from the command line
sudo fuser -v 5000/tcp // gives you the process running on port 5000
它将输出与以下所示类似的详细信息
It will output details similar to the one shown below
USER PID ACCESS COMMAND
5000/tcp: almypal 20834 F.... node
然后使用
sudo fuser -vk 5000/tcp
终止该过程.使用
sudo fuser -v 5000/tcp
以确保该过程已终止.
在Windows上,您可以使用以下步骤
On Windows you could use the following steps
C:\> tasklist // will show the list of running process'
Image Name PID Session Name Session# Mem Usage
System 4 console 0 236 K
...
node.exe 3592 console 0 8440 k
请注意与您的节点进程相对应的PID,在这种情况下为3592.接下来运行taskkill终止该进程.
Note the PID corresponding to your node process, in this case 3592. Next run taskkill to terminate the process.
C:\> taskkill /F /PID 3592
或/IM开关
C:\> taskkill /F /IM node.exe
这篇关于如何杀死Node.js上的开放进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!