Reputation: 223
I´am on a windows machine, and I understand that it is a little different here.
The problem is that I can't find any information on how I stop, kill or exit nodemon.
Upvotes: 20
Views: 54337
Reputation: 100
A simple Ctrl
+ C
isn't going to solve the issue here, although the same thing would solve it on Linux, but for some reason nodemon
doesn't respond to it on windows.
The solution is to let nodemon
know we want to exit when we receive the SIGINT
event
Starting a process:
PS C:\code\testing> pnpm --filter api run dev
The code you need to have inside of your codebase:
process.on('SIGINT', () => {
console.log('SIGINT received. Exiting...')
nodemon.emit('quit')
process.exit(0)
})
process.on('exit', () => {
console.log('Exiting...')
nodemon.emit('quit')
});
now when you press Ctrl
+ C
your code will tell nodemon
to exit.
Upvotes: 0
Reputation: 89
Go to --> C:\Users\username\AppData\Roaming\npm\node_modules\nodemon\bin. In bin folder there is windows-kill.exe file.
Upvotes: 1
Reputation: 21
With the keys ctrl + c With this you can get out of our nodemon
Or with this you can prevent the module from continuing to work
process.exit(1);
Upvotes: 2
Reputation: 517
Press Ctrl + C to exit from Nodemon on windows. If that does not work, simply end the task from task manager and run it again.
Upvotes: 0
Reputation: 1
I had issues with this until I ran command prompt as an administrator. Then Ctrl + C worked.
EDIT: Sorry, the above worked once and then stopped working. I did end up finding this article: http://www.wisdomofjim.com/blog/how-kill-running-nodejs-processes-in-windows . The command provided here (taskkill /im node.exe /F) works consistently for me on Windows, when I run it in a new command prompt window.
Upvotes: 0
Reputation: 1263
I used git bash on window and I couldn't terminate the nodemon process with ctr
+ c
, so I would terminate the node process on the task manager to use the same port. Later I found on github to why nodemon
doesn't terminate in git bash
. Anywaypowershell
should be use instead, after ctr
+ c
it will ask either to terminate batch job or not. This action will clear the process and stop nodemon.
Upvotes: 2
Reputation: 261
My experience here is that Ctrl+C leaves a node instance running in the background. If you want to kill the stack, when you try to restart 'nodemon server.js' or just 'node server.js' for that matter, you will get an EADDRINUSE error because the old node server has the port tied up. You have to find it by using ps -W | grep node
in the terminal window, because the task manager wont show it. Also you can kill it with the process ID (PID) with taskkill. The /F is the 'force' parameter. Here we will kill the task with PID 7528.
$ taskkill /F /PID 7528
Then check ps -W | grep node again, and the node server should be gone, and the server will launch again.
Their docs show a few tricks on intercepting the shutdown command, but since they use a 'rs' command to restart, they could add a 'kill' command to shutdown the daemon.
Brian
Upvotes: 25
Reputation: 29021
For purposes of completeness, The correct answer is press Ctrl + C. Or you could also find it in task manager and kill it. This applies to pretty much anything on the command line.
Upvotes: 28