node.js Grunt 手表错误 - 正在等待...致命错误:观看 ENOSPC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16748737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:36:39  来源:igfitidea点击:

Grunt watch error - Waiting...Fatal error: watch ENOSPC

node.jsgruntjs

提问by kds

Why do I get the Waiting...Fatal error: watch ENOSPCwhen I run the watch task ? How do I solve this issue?

为什么我Waiting...Fatal error: watch ENOSPC在运行 watch 任务时会得到?我该如何解决这个问题?

回答by kds

After doing some research found the solution. Run the below command.

经过一番研究,找到了解决办法。运行以下命令。

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

For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:

对于 Arch Linux,将此行添加到 /etc/sysctl.d/99-sysctl.conf:

fs.inotify.max_user_watches=524288

回答by grenade

Any time you need to run sudo something ...to fix something, you should be pausing to think about what's going on. While the accepted answer here is perfectly valid, it's treating the symptom rather than the problem. Sorta the equivalent of buying bigger saddlebags to solve the problem of: error, cannot load more garbage onto pony. Pony has so much garbage already loaded, that pony is fainting with exhaustion.

任何时候你需要跑去sudo something ...修理东西,你应该停下来想想发生了什么。虽然这里接受的答案是完全有效的,但它是在治疗症状而不是问题。这相当于购买更大的马鞍包来解决以下问题:错误,无法将更多垃圾装载到小马身上。小马已经装了这么多垃圾,小马累得快要晕倒了。

An alternative (perhaps comparable to taking excess garbage off of pony and placing in the dump), is to run:

另一种选择(可能类似于从小马身上取下多余的垃圾并放入垃圾场),是运行:

npm dedupe

Then go congratulate yourself for making pony happy.

然后去祝贺自己让小马开心。

回答by Arne L.

After trying grenade's answeryou may use a temporary fix:

尝试手榴弹的答案后,您可以使用临时修复程序:

sudo bash -c 'echo 524288 > /proc/sys/fs/inotify/max_user_watches'

This does the same thing as kds's answer, but without persisting the changes. This is useful if the error just occurs after some uptime of your system.

这与kds's answer做同样的事情,但不坚持更改。如果错误只是在系统正常运行一段时间后发生,这将很有用。

回答by Michael Lewis

To find out who's making inotify instances, try this command (source):

要找出谁在制作 inotify实例,请尝试以下命令(来源):

for foo in /proc/*/fd/*; do readlink -f $foo; done | grep inotify | sort | uniq -c | sort -nr

Mine looked like this:

我的看起来像这样:

 25 /proc/2857/fd/anon_inode:inotify
  9 /proc/2880/fd/anon_inode:inotify
  4 /proc/1375/fd/anon_inode:inotify
  3 /proc/1851/fd/anon_inode:inotify
  2 /proc/2611/fd/anon_inode:inotify
  2 /proc/2414/fd/anon_inode:inotify
  1 /proc/2992/fd/anon_inode:inotify

Using ps -p 2857, I was able to identify process 2857 as sublime_text. Only after closing allsublime windows was I able to run my node script.

使用ps -p 2857,我能够将进程 2857 识别为sublime_text. 只有在关闭所有sublime 窗口后,我才能运行我的节点脚本。

回答by Aaron

I ran into this error after my client PC crashed, the jest --watchcommand I was running on the server persisted, and I tried to run jest --watchagain.

在我的客户端 PC 崩溃后,我遇到了这个错误,我jest --watch在服务器上运行的命令仍然存在,我尝试jest --watch再次运行。

The addition to /etc/sysctl.confdescribed in the answers above worked around this issue, but it was also important to find my old process via ps aux | grep nodeand killit.

而除/etc/sysctl.conf在解决此问题上面工作的答案说明,但同样重要的是通过寻找我的老工艺ps aux | grep nodekill它。

回答by azeez

In my case it was related to vs-code running on my Linux machine. I ignored a warning which popped up about file watcher bla bla. The solution is on the vs-code docs page for linux https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

就我而言,它与在我的 Linux 机器上运行的 vs-code 有关。我忽略了一个关于文件观察器 bla bla 的警告。解决方案位于 linux https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-的 vs-code 文档页面上这个大工作区错误enospc

The solution is almost same (if not same) as the accepted answers, just has more explanation for anyone who gets here after running into the issues from vs-code.

解决方案与接受的答案几乎相同(如果不相同),只是对遇到 vs-code 问题后到达这里的任何人有更多解释。

回答by Vitaly Zdanevich

In my case I found that I have an aggressive plugin for Vim, just restarted it.

就我而言,我发现我有一个针对 Vim 的激进插件,只是重新启动了它。