Nodemon: 错误“错误:观看 ENOSPC”

创建于 2013-10-20  ·  56评论  ·  资料来源: remy/nodemon

20 Oct 16:40:37 - [nodemon] v0.7.10
20 Oct 16:40:37 - [nodemon] to restart at any time, enter `rs`
20 Oct 16:40:37 - [nodemon] watching: /my/proyect/server
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/usr/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/lib/node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
20 Oct 16:40:37 - [nodemon] reading ignore list
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at fs.watch (fs.js:1076:11)
    at checkTimer (/usr/lib/node_modules/nodemon/nodemon.js:467:27)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

最有用的评论

系统对用户可以观看的文件数量有限制。 如果您让 Grunt 与 Dropbox 等其他程序一起运行,您可能很快就会耗尽手表。

该帖子建议运行此操作以增加可用手表的数量。

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

所有56条评论

节点版本?

另外,您能否提供一个您正在使用的简单测试用例脚本(用于测试)。

使用节点 0.10.21。 使用任何脚本,都会产生错误。

这是与#144 相同的问题吗? 我无法在我的 mac 上复制它(虽然我没有问你有什么操作系统,但根据上面粘贴中的路径假设 *nix 类型)。

不一样,这里不同的是运行单个进程。 在另一个运行在多个进程上,非云

今天在使用多个应用程序(express、restify)时遇到了这个错误。

NodeJS:v0.10.21
ElementaryOS 版本:0.2“Luna”(64 位)
构建于:Ubuntu 12.04(“精确”)
内核 3.5.0-43-generic

11 Nov 17:32:38 - [nodemon] v0.7.10
11 Nov 17:32:38 - [nodemon] to restart at any time, enter `rs`
...
11 Nov 17:32:38 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/home/.../node_modules/nodemon/nodemon.js:160:6)
    at ready (/home/.../node_modules/nodemon/nodemon.js:49:22)
    at /home/.../node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

复制:

npm install nodemon
./node_modules/.bin/nodemon app.js

app.js(来自 http://nodejs.org/)

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

我在使用 CoffeeScript 时遇到了同样的错误 --watch ./node_modules/.bin/coffee --watch app/

/home/.../node_modules/coffee-script/lib/coffee-script/command.js:334
        throw e;
              ^
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at watchDir (/home/.../node_modules/coffee-script/lib/coffee-script/command.js:299:27)
    at /home/.../node_modules/coffee-script/lib/coffee-script/command.js:102:11
    at Object.oncomplete (fs.js:107:15)

我在节点为 0.10.21 的 Ubuntu 13.10 上使用 coffeescript 的复合.js 项目遇到了同样的错误

$ nodemon server.coffee

27 Nov 21:40:14 - [nodemon] v0.7.10
27 Nov 21:40:14 - [nodemon] to restart at any time, enter `rs`
27 Nov 21:40:14 - [nodemon] watching: /home/chok/work/edf/bluetic/src
27 Nov 21:40:14 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/usr/local/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/local/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/local/lib/node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

有人可以使用 nodemon 的开发版本来解决这个问题吗? 我进行了很多更改,并且正在努力集中精力确保新版本解决所有这些问题。

您可以使用npm install -g nodemon@dev

现在对我有用,不知道为什么。 使用最新的稳定 nodemon npm 版本。 也有与 coffeescript --watch 相同的问题,现在也有效。 没有节点更新,只有 npm install 模块和发行版更新。

我有同样的错误,但过程停止:

$ nodemon server.coffee 
3 Dec 15:32:42 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

@chok你能不能在你运行 nodemon 的同一个目录中为我运行以下(并粘贴结果):

find . | wc

我想知道究竟是什么导致了这个问题。

结果如下:

$ find . | wc
   7677    7677  542965

好的,这也是它试图绑定手表的 7600 个文件。

你能运行tree并将结果放在http://pastie.org/ 中吗(只是因为它会很大)。

Pastie说它太大了(超过64kb),毕竟我不喜欢底部的文字:p(你所有的粘贴都是我们的。)。 我删除了一些特定于我的项目的部分。 顺便说一句,当然,大多数文件都位于 node_modules 中。

你可以在 gist 上找到它: https :

好吧,我_认为_这是一个完全与被监控文件数量相关的问题(因为你必须绑定到每个单独的文件)。 我正在考虑默认情况下忽略 node_modules 和 .git 目录,但是您可以尝试使用 ignore 命令执行此操作吗(假设您仍在运行 0.9.x):

nodemon -i node_modules

当然,这不应该每次都需要做,我只是想确认这是问题所在。

它不起作用:(

$ nodemon -i node_modules/ server.coffee 
3 Dec 20:52:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

我也尝试:

$ nodemon -w app/* server.coffee 
3 Dec 20:53:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

您能否运行完全相同的命令,但添加--dump并向我发送响应(当您执行忽略版本时)。

没有变化:

$ nodemon -i node_modules/ server.coffee  --dump
3 Dec 21:17:18 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

嗯,对不起,你能不能在你的脚本之前加上--dump ,它应该给我一个配置的转储。

我已经试过了:(

$ nodemon -i node_modules/ --dump server.coffee 
3 Dec 21:25:35 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

你好。 我不想听起来很迟钝,但是当我遇到这个错误时,我通过增加系统上的max_user_watches来修复它。 我一直在看这个线程,看看是否还有其他事情发生。

@taylorjbrennan是的,我知道这会解决问题,但是虽然@chok能够始终如一地复制,但我正在进行更改,该更改将修复 nodemon,而无需用户执行max_user_watches io 魔术。

@remy太好了,我很期待看到它。

@chok你能不能用[email protected]再试一次 - nodemon 现在默认忽略 .git 和 node_modules/**/node_modules,所以手表的数量应该明显减少(如果这仍然是一个问题,我会重新打开) .

我还将尝试检测watch ENOSPC错误并回显有关增加max_user_watches 。 不理想,但我真的无能为力。

我已经没有这条消息了 :) 但现在我在 #245 中解释了这个问题

我刚刚遇到了这个问题,这是系统上打开的文件过多的问题。 (Sublime Text 喜欢打开大量文件,如果你愿意的话)

一旦我在 Sublime 2 中打开一个包含许多文件的目录,nodemon 就不再工作并吐出引用的错误。 我只能通过不使用 Sublimes 的“打开文件夹”功能来解决这个问题。 谢谢@eyce9000 的提示。

@timtips与 sublimetext3 和 nodemon

@baio你能不能仔细检查一下。 没有[email protected] - 有一个预发布的 @1.3.0-1 - 但它不在 npm 中生产(你也可以确认你的 npm 版本)?

他能关闭这个bug吗? 作为nodemon和nodejs的新版本,已经解决了这个问题,虽然我不能说这完全解决了。 可以说不再频繁出现。

@alejonext你能试试npm install -g nodemon@dev - 我做了很多 1.2.1 中没有的改变。

该错误实际上意味着“Error NO disk SPaCe” - 但我认为它与被监视的文件数量有关,应该通过更改观看代码来减少...

@remy作品完美 :) 感谢您的工作!!!!

甜的。 本周可能会向 npm 发布 1.3.0 的稳定版本,同时也修复了大量错误。

@remy对响应时间感到惊讶。 谢谢!

@雷米
nodemon 杀死节点中的异常
错误:观看 ENOSPC
在 errnoException (fs.js:1030:11)
在 FSWatcher.start (fs.js:1062:11)
在 Object.fs.watch (fs.js:1087:11)

节点 v0.10.33
操作系统:Linux ubuntu

我已经用这个命令解决了这个问题https://github.com/ember-cli/ember-cli/issues/1240#issuecomment -47855317

但是更新包是推荐的方式吗?

我想知道为什么它首先会变成这样。 我正在使用节点版本管理器
节点 0.12.0
npm 2.7.0
余烬 0.2.0

系统对用户可以观看的文件数量有限制。 如果您让 Grunt 与 Dropbox 等其他程序一起运行,您可能很快就会耗尽手表。

该帖子建议运行此操作以增加可用手表的数量。

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

我对"nodemon": "^1.4.1""node": "0.12.7"有这个问题:失望:

请尝试#625

在星期二,2015年9月8日16:20韦斯利奎罗斯[email protected]写道:

我在“nodemon”:“^1.4.1”和“node”:“0.12.7”[图像:
:失望的:]


直接回复此邮件或在 GitHub 上查看
https://github.com/remy/nodemon/issues/214#issuecomment -138598438。

尝试使用alpha但仍然得到ENOSPC ...
我的sysctl.conffs.inotify.max_user_watches=10000
如果我将其更改为524288就可以了,但是在我的“开发服务器”中,我将无法更改它。

您要观看多少个文件? 即有多少是你的
工作目录?

在星期二,2015年9月8日在17:37韦斯利奎罗斯[email protected]写道:

尝试过 alpha 但仍然得到 ENOSPC ......
我的 sysctl.conf 有 fs.inotify.max_user_watches=10000。
如果我将其更改为 524288 它可以工作,但是在我的“开发服务器”中我将无法
改变它。


直接回复此邮件或在 GitHub 上查看
https://github.com/remy/nodemon/issues/214#issuecomment -138624285。

不多,最多30个。
但我认为 nodemon 试图在项目的根目录下观察node_modules
下面是传递给 nodemon 的配置(我将它用作节点模块):

nodemon({
    script: 'server/server.js',
    watch: [
        'server/',
        'common/'
    ],
    ext: 'js json coffee'
});

服务器文件夹有:
7个咖啡文件
5个json文件
并且公共文件夹只有 1 个 json 文件...

是的...所以运行find . | wc -l和那个数字给你什么? 虽然默认情况下它应该忽略node_modules ,但它可能没有被考虑在内。

在项目的根目录上运行find . | wc -l给我18266但是当我删除node_modulesbower_components只给320

好的,所以我认为手表 _is_ 包括node_modules - 这是#625 重构的一部分,需要修复。

@wesleycoder您可以尝试使用最新的nodemon@dev (它应该是版本1.5.0-alpha4 )并使用DEBUG=nodemon <your normal nodemon command>运行,然后粘贴完整的输出。

哇!
有用!
没有错误!
谢谢!

这可能是因为您的系统无法访问用户可以观看的文件。 您可以在 ubuntu 中使用以下命令行
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
或尝试
npm dedupe

参考这个stackoverflow

@ankibalyan @uttampanara

有用 !
echo fs.inotify.max_user_watches=524288 | 须藤 tee -a /etc/sysctl.conf && 须藤 sysctl -p

也适用于我!
echo fs.inotify.max_user_watches=524288 | 须藤 tee -a /etc/sysctl.conf && 须藤 sysctl -p

同样在这里 ! :+1:
echo fs.inotify.max_user_watches=524288 | 须藤 tee -a /etc/sysctl.conf && 须藤 sysctl -p

运行这个命令

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

另一种可能的解决方案是在根文件夹中添加nodemon.json配置文件并指定忽略模式,例如:
nodemon.json

{
  "ignore": [
    "*.test.js", 
    "dist/*"
  ]
}
  • 请注意,默认情况下.gitnode_modulesbower_components.nyc_outputcoverage.sass-cache会被忽略,因此您不会不需要将它们添加到您的配置中。

fs 通知技巧似乎不适用于 docker 容器......至少不是 Alpine 3.8,我得到了相同的 ENOSPC 错误。 随着工具被弃用,我们仍然需要维护遗留产品,这变得越来越重要

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

piton13 picture piton13  ·  3评论

Bastorx picture Bastorx  ·  5评论

endquote picture endquote  ·  4评论

remy picture remy  ·  5评论

dimsmol picture dimsmol  ·  4评论