NodeJS - 在Windows 10上,localhost仍然运行,尽管退出nodemon
问题描述:
我使用的命令是nodemon
,而且我第一次这样做时,localhost正确地提供所有文件。然而,当我做任何改动,或当我退出了nodemon(CTRL + C)和nodemon再次运行,我得到这个错误:NodeJS - 在Windows 10上,localhost仍然运行,尽管退出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在另一个进程中执行您的程序,所以当您调用它时,您将拥有一个nodemon,并且您的应用程序在不同的进程中运行。 我的建议是为您的程序添加一个退出处理程序来关闭端口,您可以看到如何在this question中执行该操作
您是否正在以详细模式运行nodemon?它是全球安装还是本地安装?请包括完整的命令。 – cinnaroll45