Skip to content
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


Copy link

@aircloud 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

Copy link

@iamthomasbishop iamthomasbishop commented Sep 24, 2016

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

Copy link

@aircloud aircloud commented Sep 25, 2016

Yeah, it was already solved

@aircloud aircloud closed this Sep 25, 2016
Copy link

@cbcye cbcye commented Oct 2, 2016

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

Copy link

@brennanMKE 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

Copy link

@parassahu 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

Copy link

@zthornto zthornto commented Nov 18, 2016

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

Copy link

@SupriyaKalghatgi SupriyaKalghatgi commented Dec 6, 2016

None of the mentioned solutions helped me

Copy link

@brennanMKE 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.

Copy link

@dually8 dually8 commented Jan 30, 2017

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

Copy link

@jaseemabbas jaseemabbas commented Feb 5, 2017

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

Copy link

@Monte9 Monte9 commented Feb 22, 2017

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

Copy link

@mikermcneil 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

Copy link

@cmckni3 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. 😞

Copy link

@PengJuWang 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.
Copy link

@idurotola 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

Copy link

@jcollum 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.

Copy link

@lrettig 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.)

Copy link

@danmondy 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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.