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:
- tried different versions of node
- updated watchman
- reinstalled homebrew
- closed all windows/application apart from Xcode
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
2
Answers
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:
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.
We can solve this issue by the following commands