New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“Error watching file for changes: EMFILE” when run the examples from facebook/react-native/Examples #10088

aircloud opened this Issue Sep 24, 2016 · 18 comments


None yet

aircloud commented Sep 24, 2016

I want to run the Examples from facebook/react-native/Examples in OS X 10.12.

First I use npm install and then use npm start:

There is an error:

Error watching file for changes: EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"Error watching file for changes:","filename":null}
Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1008:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)

Then I use Xcode run the code but there is the same error.
Need help or advice. Thanks very much.

p.s. When I init a new project and then use react-native run-ios or Xcode , and there is the same error


This comment has been minimized.

iamthomasbishop commented Sep 24, 2016

Fwiw, I was running into the same issue, and this solved it: #910


This comment has been minimized.

aircloud commented Sep 25, 2016

Yeah, it was already solved

@aircloud aircloud closed this Sep 25, 2016


This comment has been minimized.

cbcye commented Oct 2, 2016

i use this command to resolve my problem
sudo react-native start


This comment has been minimized.

brennanMKE commented Oct 4, 2016

You really do not want to use sudo regularly, especially with software which is under development. It gives that process unrestricted access to your computer and files which opens you up to major security risks. With all of the npm modules in your Node.js you cannot know that one of them does not contain a bug which could accidentally damage files on your computer or even do this maliciously.

What you want to do is increase the maximum allowed number of file descriptors. This command will show you the current maximum.

ulimit -n

Adding a number will set the maximum to the new value. This will allow you to run the react-native command without sudo.

ulimit -n 2560


This comment has been minimized.

parassahu commented Nov 18, 2016

If you have homebrew earlier and you have upgrade to Sierra, then it can solve your problem. Run this in your terminal, then again run react-native build.

sudo chown -R $(whoami) /usr/local


This comment has been minimized.

zthornto commented Nov 18, 2016

If anyone else comes across this, installing watchman through brew ended up fixing things for me.


This comment has been minimized.

SupriyaKalghatgi commented Dec 6, 2016

None of the mentioned solutions helped me


This comment has been minimized.

brennanMKE commented Dec 6, 2016

@SupriyaKalghatgi This may help. It appears to have helped other people already.

React Native Trouble

Updating to macOS Sierra is causing trouble with React Native due to some of the Node.js and system utilities it uses. Specifically the watch utility fails due to a limit on the number of files which can be opened at a time.

The following command shows the current limit.

launchctl limit maxfiles

It may show 256 as the lower limit. The following command will change the limits.

sudo launchctl limit maxfiles 2048 unlimited

Next you also want to uninstall react-native and reinstall it so you get a version which works better with Sierra. You also want to update Homebrew and install the current version of watchman.

npm uninstall -g react-native-cli
npm install -g react-native-cli
brew update
brew install watchman

Now try building and running your React Native project on macOS Sierra.


This comment has been minimized.

dually8 commented Jan 30, 2017

Re-installing the node_modules folder worked for me. Just a thought lol.


This comment has been minimized.

jaseemabbas commented Feb 5, 2017

Reinstalling node modules worked for me too. But its a pain to do this every time.


This comment has been minimized.

Monte9 commented Feb 22, 2017

@brennanMKE You saved me like a hero! :) Thanks much!


This comment has been minimized.

mikermcneil commented Apr 18, 2017

For me, it turned out that I had npm link-ed something else (the Sails socket client in my case), which seems to have thrown things into a tizzy. Removing the linked dep and rerunning react-native-cli seemed to fix things up


This comment has been minimized.

cmckni3 commented May 16, 2017

I didn't have watchman installed. I switch between computers and thought both had it installed but I was wrong. 😞


This comment has been minimized.

PengJuWang commented Jun 22, 2017

This might be related to #4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.

This comment has been minimized.

idurotola commented Jun 23, 2017

If all the above does not work - find out if you have a permission problem with brew postinstall watchman.
error will be Error: Permission denied - /usr/local/var/run/watchman
If that is the case change the permission on the watchman directory before you try reinstalling with brew postinstall watchman
change permission with sudo chown -R "$USER":admin /usr/local/var/run


This comment has been minimized.

jcollum commented Jul 26, 2017

This sort of thing happens enough with RN that I just put an entry in my package.json:

"clean-start": "watchman watch-del-all && rm -rf node_modules && yarn install && rm -rf $TMPDIR/react* && npm start --reset-cache"

Running that fixed whatever problem I was having with this EMFILE thing.


This comment has been minimized.


lrettig commented Sep 27, 2017

I didn't have watchman installed. Simply installing via brew install watchman fixed this issue, I didn't have to make any other changes. (I'm on OS X.)


This comment has been minimized.

danmondy commented Oct 10, 2017

If you are like me, I did everything suggested but kept ignoring brew and used npm to install watchman. Using brew fixed it for me.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.