Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

windows - How to kill an open process on node.js?

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.

Is there a way I can kill the openned "node.exe" process from node.js?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Then use

   sudo fuser -vk 5000/tcp

to terminate the process. Check once again using

   sudo fuser -v 5000/tcp

to ensure that the process has terminated.

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

Note the PID corresponding to your node process, in this case 3592. Next run taskkill to terminate the process.

  C:> taskkill /F /PID 3592

Or /IM switch

  C:> taskkill /F /IM node.exe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...