jest: Error: Error watching file for changes: EMFILE

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)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 28
  • Comments: 23 (1 by maintainers)

Commits related to this issue

Most upvoted comments

brew install watchman worked for me.

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

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",

ditto to watchman

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

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

This problem exists with the following versions

  • 19.0.2
  • 19.0.1
  • 19.0.0

It works in

  • 18.1.0

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.