question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Error watching file for changes: EMFILE

See original GitHub issue

Hello, Extension shows error at output:

screen shot 2017-02-06 at 17 52 07 pm

pure node --harmony project, no babel anywhere, npm test = node --harmony node_modules/.bin/jest

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

43reactions
ntwbcommented, Dec 29, 2019

Looks like I’ve solved this for myself, for now, after reading many of the conflicting reports that watchman or fb-watchman being installed, or not installed I’ve not touched any of that for fear of perpetuating that side of things.

Anyways, I had tried removing node_modules and reinstalling, that worked once or twice, I restarted the Finder app, because, open files, again this issue kept reappearing

Next I thought that Jest was trying to watch all the files in /node_modules, wondering if like much of these tools they will inherit the ignore path from the .gitignore, went looking at the docs and no mention of Jest doing that.

Side Note: I believe testPathIgnorePatterns ignores /node_modules by default

Thus I tried adding /node_modules to watchPathIgnorePatterns

Yup, this now works for me, consistently, with this not set Jest fails to start in watch mode, setting this Jest will start and restart in watch mode successfully

"jest": {
	"watchPathIgnorePatterns": [
		"/node_modules/"
	]
}

The above is in my package.json file, I’ll try updating it in some Jest config files and shared configs a bit later

There’s a few Jest issues that state the above works as a workaround but not the ideal solution, it was supposedly fixed in Jest 24.8.0, but not for everyone and the above workaround is still required

So whilst the above works, the consensus appears to be that this is not the “right” solution, if you’ve complex projects this wouldn’t be ideal, so for now, this will work for me and I’ll keep an eye on the above linked Jest issue

5reactions
itaisircommented, Nov 30, 2020

The easiest thing would be to install Watchman:

$ brew update
$ brew install watchman

If you don’t have brew, do this first:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error watching file for changes: EMFILE #3436 - 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...
Read more >
Testing with Jest failed with Error: Error watching file for changes
Oh, I am going to answer my question after hours of my struggling. The best solution is to install the latest version of...
Read more >
Testing with Jest failed with Error: Error watching file for changes
Oh, I am going to answer my question after hours of my struggling. The best solution is to install the latest version of...
Read more >
Error on running IOS App (Example) | Treehouse Community
Collaborate here on code errors or bugs that you need feedback on, ... Error: Error watching file for changes: EMFILE at _errnoException ......
Read more >
Fix 'EMFILE: too many open files' error in Jest - SeanMcP.com
Why watchman ? ... Watchman is a file-watching service from Facebook that will respond to changes in your files. Jest (also by Facebook)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found