Create-react-app: Error: fsEvents is not a function (using Jest and create-react-app)

Created on 20 Mar 2020  路  13Comments  路  Source: facebook/create-react-app

I keep getting an error "fsEvents is not a function" when I run npm test

Fragment in package.json

"test": "react-scripts test"
Error upon running npm test

TypeError: fsevents is not a function
    at new FSEventsWatcher (node_modules/jest-runtime/node_modules/jest-haste-map/build/lib/FSEventsWatcher.js:162:20)
    at createWatcher (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:1052:23)
    at Array.map (<anonymous>)
    at HasteMap._watch (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:1230:44)
    at node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:517:21
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:193:24)
    at _next (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:213:9)

React scripts version: 3.0.1 (also tried 3.4.0) Node version: v12.16.1 npm version: 4.6.1

I have tried changing the version of Node (downgrading, upgrading to latest) - doesn't work, also downgraded npm to 4.x per another post's recommendation - doesn't work. Also tried installing the latest version of Chokidar (which I don't otherwise require as a dependency in the project).

What could be the issue?

bug report needs triage stale

Most helpful comment

i ran brew install watchman and that fixed it for me. not sure if it's because i'm using fish and fish-nvm or because i just set up a new laptop on apple's new os catalina.

still using npm, we can't switch to yarn atm

All 13 comments

i have the same type error. old advices to remove node_modules and yarn.lock or install fsevents do not work.

This did not work for me as suggested on stack overflow:

rm -rf node_modules/ package-lock.json 
npm i

Workaround that worked for me

rm -rf node_modules/ package-lock.json 
yarn

Any news on this front? I'm using npm and I can't switch to yarn.

It turned out to be the gcc I had installed. I tried the solution posted in StackOverflow and was able to fix it. https://stackoverflow.com/a/59549892/456564

i ran brew install watchman and that fixed it for me. not sure if it's because i'm using fish and fish-nvm or because i just set up a new laptop on apple's new os catalina.

still using npm, we can't switch to yarn atm

Seems like the same issue here #8703

i ran brew install watchman...

I am also running fish shell. I installed watchman and that seemed to fix the issue. Oddly enough, when I uninstalled watchman later, the issue was still resolved.

Requiring a lower version of fsevents worked for me.

npm install [email protected]

Note: Maintainers of fsevents do not recommend this tactic

Any update on this?

I faced this issue and found a solution by M Mostagir in Udemy.

Quoting him verbatim
```
If anyone still have issues with Catalina specifically developer betas. This will fix it.

  1. sudo rm -r -f /Library/Developer/CommandLineTools

This will remove xcode command line tools which was the issue with gyp rebuild, which created the problem with testing issue.

  1. xcode-select --install

Re-install the xCode command-line tools.

  1. npm install

Please run npm install, without the sudo! Also make sure you're inside the frontend folder itself.

`

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amuehl picture amuehl  路  79Comments

razvan-soare picture razvan-soare  路  161Comments

sgriffey picture sgriffey  路  113Comments

benneq picture benneq  路  99Comments

ericdfields picture ericdfields  路  78Comments