jest: --watch Now Throws an Error
🐛 Bug Report
I recently updated jest to 24.3.1
and now running with --watch
throws an error and does not start. The error is:
2019-03-08 09:51 node[1373] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
Error: Error watching file for changes: EMFILE
at _errnoException (util.js:1022:11)
at FSEvent.FSWatcher._handle.onchange (fs.js:1359:9)
I do not have watchman installed globally and again, this was working yesterday and now it’s not. I feel like it’s an issue with the macOS update but I can’t confirm. I know installing watchman via brew is a suggested solution but I’ve never had to do that before and that seems kind of like it’s masking a possible issue with jest.
To Reproduce
npx jest --watch
Expected behavior
I expected jest to continue to work correctly as it has before I updated.
Link to repl or repo (highly encouraged)
https://github.com/arb/celebrate/tree/feature-ref this is the branch I’m working with and currently exhibiting the above behavior.
Run npx envinfo --preset jest
Paste the results here:
npx: installed 1 in 1.538s
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node
Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.1/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.1/bin/npm
npmPackages:
jest: ^24.3.1 => 24.3.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 37 (14 by maintainers)
I was able to alleviate the issue in my project that is experiencing this by configuring the
watchPathIgnorePatterns
to["node_modules"]
. As expected, this lowered the number of files being watched to something below my system’s limit.https://jestjs.io/docs/en/configuration.html#watchpathignorepatterns-array-string
I confirm that ignoring the node_modules worked again:
jest@24.8.0 doesn’t solve the issue for me 😕
Seems this is still an issue for folks
Fix out in 24.7.0
It is, yes. Jest 23 worked fine. As soon as I updated to Jest 24 24.4.0 it started breaking.
People get upset when we aren’t watching node_modules because people tend to change them manually.
I had issue I see here using jest and the only way I could fix that was installing watchman. Here my environment:
If now is necessary we install watchman to run jest, why that information isn’t in Jest website (or documentation)? I needed to do a long research till I get here. Including that information into Jest page installation instruction would make jest user’s life a lot easier.
Why not just include this information somewhere in Jest website?
Problem still exists in jest@24.9.0 but configuring watchPathIgnorePatterns to ignore node_modules does fix.
@elkwood Yeah, going with an alternate solution (see https://github.com/facebook/jest/pull/8258), may revisit defaults on watching
node_modules
in the future if have more issues in this area.Or just a shallow watch of the folder, which would be nice because it would catch new modules. I’ll take a look today.
I’m learning react and I was testing redux actions, I installed es-lint to project (for no reason) and start getting the same error. Deleted node-modules and removed es-lint from the project. Everything went back to normal. I don’t think this information helps you at all 😃, but just wanted to let you know es-lint might be part of the issue as well for you guys too.
This workaround resolves the errors for me as well, thanks @elkwood. And, like @arb I too believe a code fix should fix the underlying issue.
Can confirm this workaround gets around the problem. Make sure you specify the value on the project config if you’re using multiple projects. I still believe there needs to be a code fix for this as it was working in version 23, but this is a good workaround for the current problem! 👍
Sure, I was just trying to unblock you
You can probably install
watchman
to get around this -brew install watchman
.This is probably because we removed the
fsevents
crawler (#8048). Not sure why the node crawler explodes, tho.