【问题标题】:Nodemon internal watch failed error?Nodemon内部监视失败错误?
【发布时间】:2018-04-06 21:03:00
【问题描述】:

我不知道发生了什么,但突然我的 Nodemon 开始显示错误。

nikhil@nikhil-Lenovo-Z50-70:~/Desktop/dominos$ nodemon server.js
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
[nodemon] Internal watch failed: watch /home/nikhil/Desktop/dominos 
ENOSPC

即使在那之后我的程序运行良好。但是当我关闭这个 project1 并在同一个端口上运行另一个 project2 时,就会发生这个错误

Error: listen EADDRINUSE :::3000
at Object.exports._errnoException (util.js:1024:11)
at exports._exceptionWithHostPort (util.js:1047:20)
at Server.setupListenHandle [as _listen2] (net.js:1319:14)
at listenInCluster (net.js:1367:12)
at Server.listen (net.js:1467:7)
at Object.<anonymous> (/home/nikhil/Desktop/dominos/server.js:533:8)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3

然后我的旧项目 1 将保持打开状态,并且我的新项目 2 无法启动,直到我手动终止该进程。

知道为什么会这样吗?

【问题讨论】:

  • 3000端口已被另一个进程使用
  • 是的,如果我使用 Kill 命令终止进程,那么我的项目运行良好,但从几天前开始出现这个问题,我能够在同一个端口上使用 nodemon 运行无数应用程序。

标签: node.js ubuntu-16.04 nodemon


【解决方案1】:

假设您使用的是 linux,问题可能是您有太多开放的观察者。 运行这个命令:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

然后再试一次。

信用:this answer.

【讨论】:

    【解决方案2】:

    出现此问题是因为已经有另一个进程或终端使用您的相同端口

    使用以下命令杀死所有节点

    killall node
    

    使用以下命令启动 nodemon

    nodemon server.js
    

    【讨论】:

      【解决方案3】:

      我遇到了同样的错误。节点工作,但不是 nodemon。我所做的只是:

      npm install -g nodemon
      

      它成功了?

      【讨论】:

        猜你喜欢
        • 2018-10-08
        • 2016-04-12
        • 2020-05-05
        • 2020-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-11
        • 1970-01-01
        相关资源
        最近更新 更多