我已经设置了一个新的空白反应本机应用程序。

在安装了几个节点模块后,我得到了这个错误。

Running application on PGN518.
internal/fs/watchers.js:173
   throw error;
   ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/badis/Desktop/react-native/albums/node_modules/.staging'
   at FSWatcher.start (internal/fs/watchers.js:165:26)
   at Object.watch (fs.js:1253:11)
   at NodeWatcher.watchdir (/home/badis/Desktop/react-native/albums/node modules/sane/src/node watcher. js:175:20)
   at NodeWatcher.<anonymous> (/home/badis/Desktop/react-native/albums/node modules/sane/src/node watcher. js:310:16)
   at /home/badis/Desktop/react-native/albums/node modules/graceful-fs/polyfills.js:285:20
   at FSReqWrap.oncomplete (fs.js:154:5)

我知道这与没有足够的空间让守望者监视所有文件更改有关。

我想知道在这里采取的最佳行动是什么?

我应该忽略node_modules文件夹添加到.watchmanconfig ?


当前回答

如果你使用vs代码编辑器,由于项目中有大量文件,任何编辑器都会出现错误。Node_modules和build不需要,所以在列表中删除。所有打开在vs代码文件菜单

你必须过滤不必要的文件夹文件侧边栏

进入代码>首选项>设置 在搜索设置中搜索关键字“文件:排除” 添加pettern

* * / node_modules

* * /构建

就是这样

其他回答

我在使用图书馆wifi时也遇到了同样的问题,但当我换了网络后,它工作得很好。

更改网络连接

试试这个,我面对它很长一段时间,但最后它是这样解决的,

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

之后最重要的步骤是重新启动系统。

我使用ubuntu 20服务器,我添加在文件:/etc/sysctl.conf下面一行

fs.inotify.max_user_watches = 524288

保存后执行sudo sysctl -p命令

在那之后,一切都很好!

请参考此链接[1]。Visual Studio代码中提到了对此错误消息的简要解释。我也遇到了同样的错误。在相关文件中添加以下参数将修复此问题。

 fs.inotify.max_user_watches=524288

[1] https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-wor kspace-error-enospc

我试着增加建议的数量,但它没有工作。

我看到当我登录我的虚拟机时,它显示“需要重新启动”

我重新启动VM,它工作了

sudo重启