How to stop app that node.js express 'npm start'

后端 未结 16 2013
名媛妹妹
名媛妹妹 2020-12-07 11:00

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?

相关标签:
16条回答
  • 2020-12-07 11:34

    If you've already tried ctrl + c and it still doesn't work, you might want to try this. This has worked for me.

    1. 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>

    1. 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

    0 讨论(0)
  • 2020-12-07 11:34

    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

    0 讨论(0)
  • 2020-12-07 11:34

    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

    0 讨论(0)
  • 2020-12-07 11:35
    kill $(lsof -t -i :PORT_TO_KILL)
    

    simplified version.

    0 讨论(0)
提交回复
热议问题