nodemon: Nodemon does not kill process on exit with Git Bash on Windows 10
I’m on Windows 10.
When I start a server with nodemon app.js two Node.js instance appear in the Task Manager.
If I use Git Bash command line when exit nodemon by pressing ctrl+c one of the Node.js process still running in the background, I’ve to kill that process manually to exit the server.
If I use PoweShell or Cmder/cmd it works fine, both process are killed on exit.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 25 (4 by maintainers)
Updating git bash to 2.16 fixed this.
I solved this by creating a nodemon.json file in my root directory and adding and added the following: “events”:{ “restart”:“fuser -k 8000/tcp && nodemon server” }
I’m also experiencing this issue running:
As a workaround I keep a cmd.exe shell open and just run:
taskkill /F /IM node.exeto kill Node processes. I don’t get any EADDRINUSE errors this way.I resolved the issue by using Windows PowerShell instead of git bash, it is installed with Windows so you don’t need to install anything extra. If you start your nodemon application with PowerShell and press
Ctrl + Cthen you will get the following messageTerminate batch job (Y/N)?. Entering ‘Y’ here and then pressing enter will do the job.To open PowerShell in the same way you open git bash by right-clicking inside folder, replace default CMD with PowerShell by following the steps mentioned here. After that you can just go to folder go to folder you want to open PowerShell to and press
Shift + Right Click, this will show an extra option in menu sayingOpen PowerShell window here.@remy nodemon@1.12.6 worked in my env. Thanks for the fix!
Can someone try with the latest release: nodemon@1.12.6 (on node > 4)? It uses
forkinstead ofspawnso it might solve this problem.@vapurrmaid yes, I’m using git bash, but using a gulp task to launch the process rather than npm script. In my env with nodemon v1.12.5, ctrl + c did not hang, it returned to prompt but left the node process running (thus still using the port). This was fixed with nodemon v1.12.6.
I tried to run the gulp task in an npm script. Then I observed same as you describe, ctrl+c just hung.