问题
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:
- Download, install, and agree to the XCode license
- Install brew via the terminal window at brew.sh
- Install node
- Followed the instructions in the iOS terminal window in PHPStorm
Now working!
回答7:
The following steps worked for me on MacOS:
- Updateing/Installing Homebrew from official site https://brew.sh/
- 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