Error: EMFILE: too many open files - React Native CLI

二次信任 提交于 2021-01-26 03:32:05

问题


I try to run a react-native-cli project using react-native start, and the metro bundler fails, saying the following:

events.js 187
throw er; //Unhandled 'error' event

Error: EMFILE: too many open files, watch

Emitted 'error' event on NodeWatcher isntance at:
     at NodeWatcher: checkedEmitError (.../react-native-project/node_modules/sane/src/node_watcher.js:143:12)
     at FSWatcher.emit (events.js:210:5)
     at FSEvent.FSWatcher:_handle onchange (internal/fs/watchers.js:129:12) {
   errno: -24,
   syscall: 'watch',
   code : 'EMFILE',
   filename: null
)
Process terminated. Press <enter> to close the window

回答1:


In my case, upgrading watchman did not help.

This problem started to happen after having updated Node.js.

Thanks to nvm, I came back to node v8.11.3 (I updated to v12.0.4) and this issue disappeared.

That might help some of you having the same problem...




回答2:


Just close all other files and try again. If you are running on android make sure to run cd android and ./gradlew clean before react-native run-android. If this doesn't fix, there might be problem with your file watching service. Try this

$ brew update
$ brew install watchman



回答3:


I'm using a Mac and got the EMFile error. It was resolved when I installed the file watcher

brew install watchman




回答4:


I'm using a MAC and Node v12.13.1. I upgraded watchman and the issue got resolved.

watchman 4.9.0_2 -> 4.9.0_4




回答5:


I had this issue after upgrading my node version. Downgrading was not an option in my case.

brew install watchman did not fix the issue, as watchman was already installed on my machine. brew upgrade watchman did the trick for me.




回答6:


I had a bunch of these errors along with others like Could not find "Podfile.lock", etc. after installing PHP Storm.

I did the following to correct the errors based off a combination of StackOverflow searches:

  1. Download, install, and agree to the XCode license
  2. Install brew via the terminal window at brew.sh
  3. Install node
  4. Followed the instructions in the iOS terminal window in PHPStorm

Now working!




回答7:


The following steps worked for me on MacOS:

  1. Updateing/Installing Homebrew from official site https://brew.sh/
  2. Installing Watchman: brew install watchman



回答8:


In my case I got this error after switching dev machines from Linux to OS X. None of the above worked for me until I ran brew upgrade watchman.



来源:https://stackoverflow.com/questions/58675179/error-emfile-too-many-open-files-react-native-cli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!