【问题标题】:NodeJS - On Windows 10, localhost still runs despite quitting out of nodemonNodeJS - 在 Windows 10 上,尽管退出了 nodemon,localhost 仍然运行
【发布时间】:2017-10-05 18:55:11
【问题描述】:

我正在使用命令nodemon,并且第一次这样做时,localhost 正确地提供了所有文件。但是,当我进行任何更改时,或者当我退出 nodemon(ctrl + c) 并再次运行 nodemon 时,我会收到此错误:

events.js:182
  throw er; // Unhandled 'error' event
  ^

Error: listen EADDRINUSE :::3000
    at Object._errnoException (util.js:1019:11)
    at _exceptionWithHostPort (util.js:1041:20)
    at Server.setupListenHandle [as _listen2] (net.js:1344:14)
    at listenInCluster (net.js:1385:12)
    at Server.listen (net.js:1469:7)
    at Function.listen 

  (D:\Apps\NodeJs\Test\node_modules\express\
    lib\application.js:
    618:24)
    at Object.<anonymous> 
  (D:\Apps\NodeJs\Test\app.js:95:5)
  at Module._compile (module.js:624:30)
  at Object.Module._extensions..js (module.js:635:10)
  at Module.load (module.js:545:32)
  [nodemon] app crashed - waiting for file changes before starting...

我注意到在我的进程中,Node.js:Server-side Javascript 正在运行,即使我已经杀死了我的 nodemon 进程。当我简单地运行node app.js 时,我没有问题。我知道该端口已被用于为我的文件提供服务,因此出现此错误,但我不确定为什么转义 nodemon 不会终止进程并再次释放端口?

【问题讨论】:

  • 您是否在详细模式下运行 nodemon?是全局安装还是本地安装?请包含完整的命令。

标签: javascript node.js localhost nodemon


【解决方案1】:

Nodemon 在另一个进程中执行您的程序,因此当您调用它时,您将拥有一个 nodemon,并且您的应用程序在不同的进程中运行。 我的建议是为你的程序添加一个退出处理程序来关闭端口,你可以在this question 中看到如何做到这一点

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 2023-03-26
    相关资源
    最近更新 更多