You build node.js app with express v4.x then start your app by npm start. My question is how to stop the app? Is there npm stop?
If you've already tried ctrl + c
and it still doesn't work, you might want to try this. This has worked for me.
Run command-line as an Administrator. Then run the command below to find the processID (PID) you want to kill. Type your port number in <yourPortNumber>
netstat -ano | findstr :<yourPortNumber>
Then you execute this command after you have identified the PID.
taskkill /PID <typeYourPIDhere> /F
Kudos to @mit $ingh from http://www.callstack.in/tech/blog/windows-kill-process-by-port-number-157
For windows machine (I'm on windows 10), if CTRL + C (Cancel/Abort) Command on cli doesn't work, and the screen shows up like this:
Try to hit ENTER first (or any key would do) and then CTRL + C and the current process would ask if you want to terminate the batch job:
Perhaps CTRL+C only terminates the parent process while npm start runs with other child processes. Quite unsure why you have to hit that extra key though prior to CTRL+ C, but it works better than having to close the command line and start again.
A related issue you might want to check: https://github.com/mysticatea/npm-run-all/issues/74
For production environments you should use Forever.js
It's so util for start and stop node process, you can list apps running too.
https://github.com/foreverjs/forever
kill $(lsof -t -i :PORT_TO_KILL)
simplified version.