React Native 错误:ENOSPC:达到文件观察者数量的系统限制 [英] React Native Error: ENOSPC: System limit for number of file watchers reached

查看:109
本文介绍了React Native 错误:ENOSPC:达到文件观察者数量的系统限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个新的空白 React Native 应用.

I have setup a new blank react native app.

安装几个节点模块后,我收到此错误.

After installing few node modules I got this error.

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)

我知道这与没有足够的空间让守望者观察所有文件更改有关.

I know it's related to no enough space for watchman to watch for all file changes.

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

I want to know what's the best course of action to take here ?

我是否应该通过将 node_modules 文件夹添加到 .watchmanconfig 来忽略它?

Should I ignore node_modules folder by adding it to .watchmanconfig ?

推荐答案

Linux 使用 inotify 包以观察文件系统事件、单个文件或目录.

Linux uses the inotify package to observe filesystem events, individual files or directories.

由于 React/Angular 在保存时热重载和重新编译文件,它需要跟踪所有项目的文件.增加 inotify 监视限制应该会隐藏警告消息.

Since React / Angular hot-reloads and recompiles files on save it needs to keep track of all project's files. Increasing the inotify watch limit should hide the warning messages.

你可以尝试编辑

# insert the new value into the system config
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

# check that the new value was applied
cat /proc/sys/fs/inotify/max_user_watches

# config variable name (not runnable)
fs.inotify.max_user_watches=524288

这篇关于React Native 错误:ENOSPC:达到文件观察者数量的系统限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆