SuperUberDuper
SuperUberDuper

Reputation: 9633

React native error: Error: watch EMFILE

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> 

Upvotes: 7

Views: 11845

Answers (4)

Etheryte
Etheryte

Reputation: 25325

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

Upvotes: 18

Taha khozooie
Taha khozooie

Reputation: 11

Run rm -rf node_modules && npm install Maybe help.

Upvotes: -2

pg2286
pg2286

Reputation: 1021

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

Upvotes: 1

4lejandrito
4lejandrito

Reputation: 182

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

Upvotes: 2

Related Questions