简体   繁体   中英

React Native Error: EMFILE: too many open files, watch

Getting the following error and not 100% sure why. Currently getting this issue when I run my app in ios simulator

I've tried to do npm install watchman, But I just saw the latest update on the npm packages and it seems like it's been depreciated.

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:127:28)
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.checkedEmitError 
    at FSWatcher.emit (events.js:315:20)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:133:12) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  filename: null
}

This error was caused by watchman.

You should run brew install watchman in the terminal.

If watchman fails to install, you should change the ownership of these directories to your user by

sudo chown -R $(whoami) /usr/local/etc/bash_completion.d /usr/local/lib/pkgconfig /usr/local/var/log

please refer to the tips in your terminal.

Finally you run brew install watchman . The problem should be solved.

For people with Mac M1 who are running into this problem, I tried the above brew install and upgrade watchman but they didnt work. My specific problem was that react-native project would build on the simulator fine through 'npm run ios' but when archiving or building through xcode I would get this error. After hours upon hours this is what did:

  • Go into your Security in your System Preferences of your Mac and give full disk access to watchman
  • The project you are building for some reason (Probably because Apple restricts access) does not work when in your Desktop or your Documents location. Once I moved it to under /Users/myname/ it finally built and archived in xcode.

Hopefully this will save someone else the 6 hours I spent debugging and trying to figure out this.

EDIT: THIS BROKE AGAIN SO HAD TO FOLLOW THIS NEXT TO FIX IT:

This error is because of a bug in module fsevents for mac m1 silicon. See the thread: https://github.com/facebook/metro/issues/668

It got fixed with new version of watchman. Upgrade your watchman through brew. Delete your project and download from git and rebuild everything along with pod install and then it should archive no problem.

In my case (M1 Mac Mini) it was the homebrew installation. I reinstalled homebrew using this kind of iTerm2 Setup: Correct way to Install and use Homebrew on M1 Macs and brew install watchman . Afterwards it compiled without a hitch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM