node.js Nodemon 错误:已达到文件观察者数量的系统限制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53930305/
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 18:56:34  来源:igfitidea点击:

Nodemon Error: System limit for number of file watchers reached

node.jsgraphqlnodemon

提问by Rehan Sattar

I'm learning graphqland using prisma-bindingfor graphql operations. I'm facing this nodemonerror while I'm starting my node server and its giving me the path of schema file which is auto generated by a graphql-cli. Can anyone tell me what this error is all about?

我正在学习graphql和使用prisma-bindinggraphql 操作。我在nodemon启动我的节点服务器时遇到了这个错误,它给了我由graphql-cli. 谁能告诉我这个错误是怎么回事?

Error:

错误:

Internal watch failed: ENOSPC: System limit for number of file watchers reached, watch '/media/rehan-sattar/Development/All projects/GrpahQl/graph-ql-course/graphql-prisma/src/generated

回答by Isac Moura

If you are using Linux, your project is hitting your system's file watchers limit

如果您使用的是 Linux,您的项目就会达到系统的文件观察者限制

To fix this, on your terminal, try:

要解决此问题,请在您的终端上尝试:

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

回答by Juri Sinitson

I sometimes get this issue when working with VSCode on my Ubuntu machine.

在我的 Ubuntu 机器上使用 VSCode 时,我有时会遇到这个问题。

In my case the following workaround helps:

在我的情况下,以下解决方法有帮助:

stop the watcher, close VScode, start the watcher, open VSCode again.

停止观察器,关闭 VScode,启动观察器,再次打开 VSCode。

回答by cjs

You need to increase the inotifywatchers limit for users of your system. You can do this from the command line with:

您需要增加系统用户的inotify观察者限制。您可以从命令行执行此操作:

sudo sysctl -w fs.inotify.max_user_watches=100000

That will persist only until you reboot, though. To make this permanent, add a file named /etc/sysctl.d/10-user-watches.confwith the following contents:

不过,这只会持续到您重新启动。要使其永久化,请添加一个以/etc/sysctl.d/10-user-watches.conf以下内容命名的文件:

fs.inotify.max_user_watches = 100000

After making the above (or any other) change, you can reload the settings from all sysctl configuration files in /etcwith sudo sysctl -p.

在进行以上(或任何其他)的改变后,你可以重新从所有sysctl的配置文件的设置/etcsudo sysctl -p

回答by Manuel Lazo

In order to test the changes, I set temporary the parameter with the value 524288.

为了测试更改,我临时设置了值为 524288 的参数。

sysctl -w fs.inotify.max_user_watches=524288

then I proceed to validate :

然后我继续验证:

npm run serve

And the problem was solved, in order to make it permanent, you should try to add a line in the file "/etc/sysctl.conf" and then restart the sysctl service :

问题解决了,为了让它永久化,你应该尝试在文件“/etc/sysctl.conf”中添加一行,然后重新启动sysctl服务:

cat /etc/sysctl.conf |tail -n 2
fs.inotify.max_user_watches=524288

sudo systemctl restart systemd-sysctl.service

回答by Fernando Silva Maransatto

On Linux, I've actually run with sudo. sudo npm start

在 Linux 上,我实际上是用 sudo 运行的。 sudo npm start