Jest: Error: Error watching file for changes: EMFILE

Created on 2 May 2017  ·  22Comments  ·  Source: facebook/jest

I know others have posted this issue, but it seems that they are aging and using old versions. I have tried everything from other issues.

Here is the error I get:

$ jest --watch # or with $ jest --watch --no-watchman
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-02 09:49 node[8980] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1376:11)
error Command failed with exit code 1.

Versions:

  • node: v7.9.0
  • jest: 19.0.2
  • watchman: 4.7.0 (installed via brew)
  • mac: Sierra 10.12.4 (16E195)

Most helpful comment

brew install watchman worked for me.

All 22 comments

This problem exists with the following versions

  • 19.0.2
  • 19.0.1
  • 19.0.0

It works in

  • 18.1.0

Does it happen in v20?

Yes, the error is present in v20.0.0.

2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-08 05:30 node[6062] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1376:11)
error Command failed with exit code 1.

And have you tried it with watchman (brew install watchman)?

Yes

Any chance for a repro? It's hard to debug without it :(

brew install watchman worked for me.

Same here, it did not work with jest --watch or jest --watch --no-watchman (watchman was not installed):

2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2017-05-28 18:57 node[17087] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1050:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1374:11)

I installed watchman using brew, and jest --watch now works. jest --watch --no-watchman still fails.

Jest v20.0.4
Node v7.10.0
MacOS 10.12.5

I get similar error when i install "pact" and then i tried to run npm test. I using create-react-app to setup my project and using node v7.9.0

new sane version fixed this error for me see https://github.com/amasad/sane/pull/97#issuecomment-309203580

Same problem,
MAC OS X Sierra
Node v7.8.0
Jest ^20.0.4

brew install watchman worked for me too using NodeJS v6.9 but what I don't understand is the watchman dependence itself. Is this a dependency of the NodeJS version on Mac OS X Sierra? Where does this fit in the dependency tree?

brew install watchman worked for me.

I had this error, but found that if I changed the command I used to run jest in watch mode, it worked.

"test": "jest",
"test:watch": "npm run test -- --watch",

became:

"test": "jest",
"test:watch": "npm run test --watch",

brew install watchman worked... until it didn't... :-/ quit my tests and ran it again. And we're back at square one. uninstalled watchman, reinstalled watchman. no-dice.

brew install watchman worked for me. And I think watchman had gotten broken somehow because I accidentally closed a terminal window while installing a react package using npm. Clean installing everything both in the project and globally didn't seem to help, but re-installing watchman did.

Yeah! brew install watchman for work

Yeah! brew install watchman for work (2)

Yeah! brew install watchman for work (3)

ditto to watchman

I had this error, but found that if I changed the command I used to run jest in watch mode, it worked.

"test": "jest",
"test:watch": "npm run test -- --watch",

became:

"test": "jest",
"test:watch": "npm run test --watch",

The extra -- is the delimiter that tells npm to forward the remaining parameters to the referenced script.

npm run test -- --watch would run jest --watch but npm run test --watch would ignore the argument and just run jest. You can verify this in your console output.

Was this page helpful?
0 / 5 - 0 ratings