当使用Nodemon
时,我不断得到EADDRINUSE
错误,告诉我端口目前在其他地方使用,即使它不是。
这个错误几乎每次我保存文件时都会出现,但在我再次按save(或两次)后,它会清除,程序正常运行。
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8800
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
at Function.listen (/home/jake/Documents/Dev/Node-REST-API/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/jake/Documents/Dev/Node-REST-API/index.js:31:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 8800
}
[nodemon] app crashed - waiting for file changes before starting...
"dependencies": {
"bcrypt": "^5.0.1",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"helmet": "^4.6.0",
"mongoose": "^6.0.12",
"morgan": "^1.10.0"
},
"devDependencies": {
"nodemon": "^2.0.14"
}
这只是一个烦恼。有什么我能做的吗?
我有同样的问题,但只有在使用nodemon
与dotenv
相结合时。
删除我的文件顶部的require("dotenv").config();
确实可以防止nodemon在保存后崩溃,但正如你可能猜到的那样,这会创建另一个使用环境的问题。