Before I start, this isn't a duplicate of this problem (Error: EMFILE: too many open files - React Native CLI ), because although the error message is the same, the solutions does not work. I tried all the solutions there --- installing brew and running brew commands (it did not work --- home brew started infinitely installing things, taking up several gb of my disk space before I put a stop to it), updating npm to the version that others working on this project are using, etc, does not work (perhaps I've done so incorrectly somehow?)
So I recently joined in on a react native and expo project. I'm on macOS and using vscode, and I cloned with --recursive. After running npm i, this is my package.json:
{
"version": "1.0.0",
"main": "expo-router/entry",
"scripts": {
"start": "expo start",
"format": "npx prettier --write .",
"check": "npx prettier --check .",
"eslint": "npx eslint . --ext js --ext jsx",
"lint:fix": "eslint --fix --ext .js,.jsx .",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"prepare": "husky install"
},
"dependencies": {
"@expo/vector-icons": "^13.0.0",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"eslint-config-prettier": "^9.1.0",
"expo": "~49.0.15",
"expo-app-loading": "^2.1.1",
"expo-constants": "~14.4.2",
"expo-font": "~11.4.0",
"expo-image": "~1.3.5",
"expo-linear-gradient": "~12.3.0",
"expo-linking": "~5.0.2",
"expo-router": "^2.0.0",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.72.10",
"react-native-email": "^2.1.0",
"react-native-gesture-handler": "~2.12.0",
"react-native-reanimated": "~3.3.0",
"react-native-responsive-fontsize": "^0.5.1",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-web": "^0.19.10",
"validator": "^13.11.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-react": "^7.33.2",
"husky": "^9.0.11",
"prettier": "^3.2.5",
"pretty-quick": "^4.0.0"
},
"private": true,
"resolutions": {
"metro": "0.76.0",
"metro-resolver": "0.76.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css,md}": [
"prettier --check",
"eslint --fix",
"git add"
]
}
}
Then, I run npx expo start -c. It works on everyone elses device, but for me this appears
› Press s │ switch to development build
› Press a │ open Android
› Press i │ open iOS simulator
› Press w │ open web
› Press j │ open debugger
› Press r │ reload app
› Press m │ toggle menu
› Press o │ open project code in your editor
› Press ? │ show all commands
Logs for your project will appear below. Press Ctrl+C to exit.
node:events:496
throw er; // Unhandled 'error' event
^
Error: EMFILE: too many open files, watch
at FSWatcher._handle.onchange (node:internal/fs/watchers:207:21)
Emitted 'error' event on NodeWatcher instance at:
at FSWatcher._checkedEmitError (/Users/shiqizhou/github projects/Front-End/node_modules/metro-file-map/src/watchers/NodeWatcher.js:134:12)
at FSWatcher.emit (node:events:518:28)
at FSWatcher._handle.onchange (node:internal/fs/watchers:213:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
Node.js v20.12.1`
I'm not sure what to do. It seems to me that this problem mostly applies only to macOS and people on xcode, but for me its happening on vscode. I'm not sure if this is helpful information.
Any follow up questions, answers, comments, suggestions, will be greatly appreicated!
I encountered the same issue and tried all the commonly suggested solutions without success. However, I found a solution that worked for me:
Clear Watchman Watches:
I ran the following command to clear all watches and associated triggers:
watchman watch-del-all
This command removes all file watches, resolving the issue of "too many open files." It worked perfectly for me after trying numerous other solutions that didn't help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With