Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native error: Error: watch EMFILE

Tags:

react-native

I just started my 1st react native app following this:

http://www.raywenderlich.com/99473/introducing-react-native-building-apps-javascript

However when I run a build I get the following: is it important?

[5:24:30 PM] <START> Building Dependency Graph
[5:24:30 PM] <START> Crawling File System
 ERROR  watch EMFILE
{"code":"EMFILE","errno":"EMFILE","syscall":"watch"}
Error: watch EMFILE
    at exports._errnoException (util.js:746:11)
    at FSWatcher.start (fs.js:1172:11)
    at Object.fs.watch (fs.js:1198:11)
    at NodeWatcher.watchdir (/Users/me/PhpstormProjects/foo/node_modules/react-native/node_modules/sane/src/node_watcher.js:144:20)
    at Walker.<anonymous> 
like image 642
SuperUberDuper Avatar asked Oct 05 '15 16:10

SuperUberDuper


3 Answers

I ran into the same issue updating to macOS Sierra, however, it turned out that watchman was to blame. Looking through the logs I stumbled upon numerous odd permission issues.

As covered on github/facebook/react-native#9943, reinstalling watchman solves the issue.

rm -rf /usr/local/var/run/watchman/
brew uninstall watchman
brew install watchman
like image 87
Etheryte Avatar answered Oct 14 '22 08:10

Etheryte


EMFILE is an error that occurs when too many files are open by a single process. I had the same problem with a different tech stack this week. You can avoid the error by increasing the limit of open files using the ulimit command.

ulimit 4096 # for instance

You should probably try to figure out why so many files are open. Maybe your watch task is watching files inside node_modules folder or the like.

Hope it helps

like image 29
4lejandrito Avatar answered Oct 14 '22 08:10

4lejandrito


I was encountering this issue on MAC OS (Sierra) and the way to solve it was by following the steps below on terminal:

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

Credit: https://github.com/facebook/react-native/issues/10088

like image 28
pg2286 Avatar answered Oct 14 '22 08:10

pg2286