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

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

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 ?


当前回答

如果你已经添加了2个修复:fs.inotify.max_user_watches=524288

重启机器,一切都会恢复正常的 将引起问题的文件夹(对我来说是node_modules)重命名为任意名称(node_modilesa),然后重新命名。这将删除linux放在这些文件夹上的手表。允许您再次正常编码。

其他回答

验证最简单的方法,它是为我工作良好。

步骤1:停止服务器

第二步:手动删除' '下的'cache'文件夹。Angular的文件夹

步骤3:启动服务器

正如@snishalaka已经指出的,你可以增加inotify观察者的数量。

但是,我认为默认值已经足够高了,只有在没有正确清理进程时才会达到这个值。因此,我只是重新启动了我的电脑,就像在相关的github问题上提出的那样,错误消息消失了。

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

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

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

我通过使用sudo解决了这个问题 即

sudo yarn start

or

sudo npm start

使用sudo来解决这个问题将迫使观察者的数量增加,而不应用任何修改系统设置。不建议使用sudo来解决这类问题,尽管这是一个必须由您做出的选择,希望您明智地选择。

删除react node_modules

rm -r node_modules

yarn or npm install

yarn start or npm start

如果发生错误,请再次使用此方法