I've tried to build a react-native project on my MacBook Pro, but when running the command:
npx react-native start
I get the error:
Error: EMFILE: too many open files, watch
There are several solutions online, but they are scattered, so I am here to summarize.
Solution1: watchman
brew install watchman
The watchman utility enables React-Native to watch file changes.
Solution 2: change Node.js version with nvm
Run the command below to check the Node version:
nvm current
Switch Node version by:
nvm install --<the node version>
nvm use <version_number>
For example:
nvm install 12.18.3
nvm use 12.18.3
To see all Node versions you've installed, use:
nvm ls
To see all published Node versions, use:
nvm ls-remote
Usually, we should try several versions. Newest(v22.8.0), new(v20.0), and old (v17.3). This should solve the problem.
Reference:
1.https://flaviocopes.com/react-native-emfile-too-many-open-files/
2.https://flatirons.com/blog/how-to-set-a-default-node-version-with-nvm/
3.https://blog.logrocket.com/how-switch-node-js-versions-nvm/
Top comments (0)