When I tried to run
jest --watch in a codebase, I received the following error:
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (fs.js:1372:28)
Emitted 'error' event at:
at NodeWatcher.checkedEmitError (/Users/seanmcp/dev/REPO/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (events.js:182:13)
at FSEvent.FSWatcher._handle.onchange (fs.js:1378:12)
Watchman is a file-watching service from Facebook that will respond to changes in your files. Jest (also by Facebook) default to using watchman in
Watchman is available on all major platforms. On a Mac or Linux with Homebrew installed, you can run:
brew install watchman
With that installed, Jest’s
--watch flag works as expected.
I hope that works for you (and saves you some valuable time)!