【发布时间】:2019-01-02 10:27:13
【问题描述】:
我使用的是 nodemon 版本 1.18.3 和 express 版本 4。 直接运行 nodemon 命令时,出现以下错误:
events.js:165
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1346:14)
at listenInCluster (net.js:1387:12)
at Server.listen (net.js:1475:7)
at Function.app.listen (/home/rishabh/Documents/my_projects/getting_MEAN/loc8r/node_modules/express/lib/application.js:531:24)
at Object.<anonymous> (/home/rishabh/Documents/my_projects/getting_MEAN/loc8r/bin/www:7:18)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1366:8)
at process._tickCallback (internal/process/next_tick.js:178:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
[nodemon] app crashed - waiting for file changes before starting...
Nodemon 崩溃并继续等待文件更改。
【问题讨论】:
-
试试这个
echo fs.inotify.max_user_watches=524298 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p。让我知道它是否修复,然后我可以回答。 -
nodemon 使用名为
inotify watchers的东西,它允许nodemon监视您的文件系统。不幸的是,当这个限制超过 nodemon 时,nodemon 无法观察代码的变化。这里提到了这一点:github.com/guard/listen/wiki/… -
这是因为您的文件有一些错误或您的代码有一些错误。 Nodemon 会告诉您纠正应用程序中的所有错误。在所有错误消失之后 nodemon 自动启动服务器。
-
@PrashantGupta 如果是这样的话,那么它不应该在端口 3000 上给出监听错误。
-
@RishabhGupta 请发布您的代码。
标签: javascript node.js nodemon