15

When I run react-scripts test --env=jsdom it always display:

2018-07-04 09:57 node[61600] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-04 09:57 node[61600] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-04 09:57 node[61600] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (fs.js:1370:28)
Emitted 'error' event at:
    at FSEvent.FSWatcher._handle.onchange (fs.js:1376:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! stampling@0.1.0 test: `react-scripts test --env=jsdom`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the stampling@0.1.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alexis/.npm/_logs/2018-07-04T07_57_39_147Z-debug.log

npm version: 6.1.0
I am under macOS High Sierra 10.13.5

I have seen other issue like this but they have that with watchman that I don't use.

Thanks for help.

Tryliom
  • 111
  • 1
  • 17
Tryliom
  • 895
  • 1
  • 12
  • 37

5 Answers5

25

try it:

brew install watchman

It worked to me.

Felipe Amorim
  • 274
  • 3
  • 2
  • I have already tried that and I got a new error after, it works but I don't know why – Tryliom Jul 09 '18 at 08:10
  • does anyone really know what causes this many files to be opened up when running tests? Is it watching `node_modules` or something to have that many files watched? Just trying to figure out why i only have 1 test and 1 app file and its failing on too many open files – britztopher Aug 01 '18 at 01:23
4

I ran into the same issue and this is what it worked for me:

  • 1) delete package-lock.json
  • 2) npm cache clean --force
  • 3) wait 1 min.
  • 4) npm-install, this will create our new package-lock.json ( npm notice created a lockfile as package-lock.json )

Found out my global packages were corrupted

  "react-dom": "^16.0.0",
  <<<<<<< HEAD
  "react-router-dom": "^4.3.1",
  =======
  "react-router-dom": "^4.1.2",
  >>>>>>> 83340ffacc1ea542b788d66484413578afd4ef4c
  "react-scripts": "^1.1.4"
Tryliom
  • 895
  • 1
  • 12
  • 37
3

I had this issue because of a wrong version of node installed.

2

I got the same issue in react native expo project

Error

I have tried many ways

  • Restart server
  • yarn reset then restart the server
  • Restart system
  • update brew
  • Close all files and apps (As it was showing too many files open)

But nothing worked for me

- brew install watchman
- brew upgrade watchman
- Restart expo server

Worked for me finally

Mob Dev
  • 854
  • 4
  • 9
1

I found the problem.

When I put a single file in my home directory, it gives me same error. The reason is, it is trying to monitor all files under all subdirectories which is huge!!!!

when I run the command inside the folder project, its no longer gives me any error

Hope this helps.

Alex Rizvi
  • 109
  • 1
  • 6