Tom
Tom

Reputation: 243

EMFile: too many open files, watch - building Release react native iOS app

I wrote my React Native app using Expo, and then ejected it using expo eject. I am now trying to build release versions of the app. It works fine for Android, and also for debug builds for iOS, but when I try to build for release on Xcode I get the following error:

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:178:28)
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.checkedEmitError (/node_modules/sane/src/node_watcher.js:143:12)
    at FSWatcher.emit (events.js:400:28)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:184:12) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  filename: null
}

I have seen a few other people with similar errors, and tried the following steps with no luck:

I have a feeling the error is to do with the M1 chip, but am really struggling to find a solution, so any help is appreciated.


Device - Mac mini (M1, 2020), running macOS Monterey 12.0.1

Node Version - 17.0.1

React Native Version - ~0.63.4

I used this article for setting up the environment

Let me know if you require anymore information/snippets

Upvotes: 7

Views: 2194

Answers (2)

JAK
JAK

Reputation: 6491

We can solve this issue by the following commands

brew install watchman

sudo launchctl limit maxfiles 16384 16384 && ulimit -n 16384

Upvotes: 0

Redseb
Redseb

Reputation: 329

I had the same issue earlier this year. It was indeed because of the M1 chip and XCode not building properly when watchman was installed without Rosetta.

I was building on an M1 Mac using XCode 12.5 and had to:

  • Install watchman on using an x86_64 instance of homebrew
  • Run the metro server in a Rosetta terminal
  • Run XCode without Rosetta

If this is the first time you're installing a package using the x86_64 instance of homebrew remember to add it to your PATH.

Upvotes: 1

Related Questions