Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.0 with Node v12/NPM 6.9.0 gives "TypeError: fsevents is not a constructor" #6891

Closed
DominicTobias opened this issue Apr 24, 2019 · 55 comments

Comments

@DominicTobias
Copy link
Contributor

commented Apr 24, 2019

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes, tried clean install use Node v12 and NPM 6.9.0

Which terms did you search for in User Guide?

Anything about fsevents errors.

Environment

System:
OS: macOS 10.14.4
CPU: x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
Binaries:
Node: 12.0.0 - /usr/local/bin/node
Yarn: 1.15.2 - ~/.npm-global/bin/yarn
npm: 6.9.0 - ~/.npm-global/bin/npm
Browsers:
Chrome: 73.0.3683.103
Safari: 12.1
npmPackages:
react: ^16.8.6 => 16.8.6
react-dom: ^16.8.6 => 16.8.6
react-scripts: 3.0.0 => 3.0.0
npmGlobalPackages:
create-react-app: 2.1.8

Don't know why it says create-react-app: 2.1.8, if I do npm show create-react-app version it echos 3.0.0.

Steps to Reproduce

Install with NPM 6.9.0

Expected Behavior

npm start starts the server

Actual Behavior

fsevents throws:

/Users/.../node_modules/chokidar/lib/fsevents-handler.js:28
  return (new fsevents(path)).on('fsevent', callback).start();
          ^

TypeError: fsevents is not a constructor
    at createFSEventsInstance (/Users/.../Projects/fileflow/app/node_modules/chokidar/lib/fsevents-handler.js:28:11)
    at setFSEventsListener (/Users/.../Projects/fileflow/app/node_modules/chokidar/lib/fsevents-handler.js:82:16)
    at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/.../Projects/fileflow/app/node_modules/chokidar/lib/fsevents-handler.js:252:16)
    at FSWatcher.<anonymous> (/Users/.../Projects/fileflow/app/node_modules/chokidar/lib/fsevents-handler.js:386:25)
    at LOOP (fs.js:1622:14)
    at processTicksAndRejections (internal/process/task_queues.js:81:9)

Because even though chockidar depends on fsevents 1.2.8, it doesn't get installed, possibly due to chockidar declaring it as an optional dependency: https://github.com/paulmillr/chokidar/blob/master/package.json#L24

Screenshot 2019-04-24 at 22 20 03

Instead fsevents v2 gets installed which has a different API which exports a plain object (new keyword breaks on it).

⚠️ Works using yarn. (and older NPM versions as it worked on Node v11 I was using yesterday)

Reproducible Demo

Do create-create-app using NPM 6.9.0 and try to run it.

@DominicTobias DominicTobias changed the title v3.0.0 with Node v12 gives "TypeError: fsevents is not a constructor" v3.0.0 with Node v12/NPM 6.9.0 gives "TypeError: fsevents is not a constructor" Apr 24, 2019

@fmolina94

This comment has been minimized.

Copy link

commented Apr 25, 2019

I had the same issue. How did you solve it?

@fsepulveda

This comment has been minimized.

Copy link

commented Apr 25, 2019

Same issue...
TypeError: fsevents is not a constructor

node: v12.0.0
npm: 6.9.0
create-react-app: 3.0.0

@fmolina94

This comment has been minimized.

Copy link

commented Apr 25, 2019

I had the same issue. How did you solve it?

Updated 22:30
This worked for me:

  1. I deleted my react app because I realized I did not have yarn installed.
  2. So I installed yarn.
  3. Then, again I did npx create-react-app my-app, and it worked. The issue disappeared.

Other things I did:

  • Installed node globally
  • Cleared the node caché
@DominicTobias

This comment has been minimized.

Copy link
Contributor Author

commented Apr 25, 2019

For now you can downgrade Node, or remove node_modules and package-lock.json and do yarn install instead. Author of chokidar package said it will be fixed in upcoming v3.

@NathanCH

This comment has been minimized.

Copy link

commented Apr 25, 2019

This issue is very common.

See #6657 (reported by me), #2558, #3588, #4308.

Unfortunately all these threads lead to dead-ends. I've reproduced this error on a fresh, brand new iMac and on my Windows PC. For some reason it's never drawn any attention.

@joshunger

This comment has been minimized.

Copy link

commented Apr 25, 2019

It looks like Node.js v12 removed v8::Handle which fsevents@1.2.8 uses. See https://electronjs.org/blog/nodejs-native-addons-and-electron-5.

You can reproduce:

nvm use 12
yarn init
yarn add fsevents@1.2.8

Output:

  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
../fsevents.cc:43:32: error: no template named 'Handle' in namespace 'v8'
    static void Initialize(v8::Handle<v8::Object> exports);
@sam-github

This comment has been minimized.

Copy link

commented Apr 25, 2019

Fix in fsevents/fsevents#271, waiting on nodejs/nan#849

@amitpatil321

This comment has been minimized.

Copy link

commented Apr 28, 2019

Giving up npm and using yarn helped me.
I removed node_modules package.lock yarn.lock and then cleared npm cache with --force.

and then yarn install and yarn run...and its working!

@jonathanjouret-ls

This comment has been minimized.

Copy link

commented May 2, 2019

FYI:

For me, removing node_module and yarn.lock then running yarn fixed the issue

@galohernandez

This comment has been minimized.

Copy link

commented May 5, 2019

I solved installing yarn and then sudo forever npm and node_modules. Try this https://timonweb.com/posts/install-npm-packages-without-sudo/ for permission issues. After that I created a new project and finally i go the dev server on

@faustorenier

This comment has been minimized.

Copy link

commented May 5, 2019

I had the same issue. How did you solve it?

Updated 22:30
This worked for me:

  1. I deleted my react app because I realized I did not have yarn installed.
  2. So I installed yarn.
  3. Then, again I did npx create-react-app my-app, and it worked. The issue disappeared.

Other things I did:

  • Installed node globally
  • Cleared the node caché

Worked for me, thanks mate!

@george-afrah

This comment has been minimized.

Copy link

commented May 6, 2019

For now you can downgrade Node, or remove node_modules and package-lock.json and do yarn install instead. Author of chokidar package said it will be fixed in upcoming v3.

This worked for me so well that I would recommend to any one in my situation, this morning.
what happen to me: I've cloned react app() from github to local machine with:

  • macosx (10.12.6)
  • Node v10.15.3 and NPM v6.9.0
  • and then I tried to "npm intall" to get down all dependencies as usual, and then I've tried to run the devServer by running the command: " npm start " to my surprice, npm quited with error above.
    For me 'destroying' the whole react app was not an option, so I have just removed the node_modules folder and also deleted the package-lock.json, as suggested by DominicTobias and then installed yarn globally by using the MacPorts utility
    After installing yarn, I've cd to the react app project on the local machine, and then executed the command: "yarn run start" And voilà! everything starting running as expected.
    many thanks to DominicTobias
@Shahor

This comment has been minimized.

Copy link

commented May 10, 2019

"resolutions": {
    "fsevents": "
}

Resolved the issue temporarily by adding this to my package.json.

Until chokidar releases their next version, the api is fully compatible with latest version so it should work just fine 👍

@yairEO

This comment has been minimized.

Copy link

commented May 19, 2019

@Shahor - Did as suggested but still not working :/

@donlequy

This comment has been minimized.

Copy link

commented May 23, 2019

all my problems i've got is from fsevents
why so terrible :(

@alan345

This comment has been minimized.

Copy link

commented May 23, 2019

rm -rf node_modules
rm -f yarn.lock 
yarn

Solve the issue

@majda

This comment has been minimized.

Copy link

commented May 29, 2019

Downgrading node version solves the issue.

Please note that I have uninstalled all versions of the Node on my machine (and yarn as well), and then, instead of installing Node manually, installed nvm. This allows you to switch between different versions of Node easily.

Once nvm is installed run nvm install node to install the specific version (I have installed 10.15.3)

To change Node version run nvm use <version>

Check you're set up correctly by running node -v

@udhayakumaran

This comment has been minimized.

Copy link

commented May 29, 2019

Giving up npm and using yarn helped me.
I removed node_modules package.lock cleared npm cache with --force.

and then yarn install and yarn run...and its working!

This solution from @amitpatil321 worked for me. 👍

@klimsava

This comment has been minimized.

Copy link

commented Jun 2, 2019

very good way, thanks @majda

@paigen11

This comment has been minimized.

Copy link

commented Jun 3, 2019

Same issue using node v11.10.0 and npm v6.9.0, my issue was solved as well by deleting the yarn.lock and node_modules and running yarn again. I hope this gets fixed soon - it's very annoying to do a fresh install and have it break immediately when I try to launch the app

@diegodesouza

This comment has been minimized.

Copy link

commented Jun 3, 2019

@DominicTobias What version of node works for you? I have tried several and yet no luck

@DominicTobias

This comment has been minimized.

Copy link
Contributor Author

commented Jun 3, 2019

@DominicTobias What version of node works for you? I have tried several and yet no luck

The LTS version works (10.6.0), I have 10.5.3

@matthewstitt42959

This comment has been minimized.

Copy link

commented Jun 7, 2019

I was recently able to resolve this issue by going into the Node_module folder and finding fsevents folder. I changed the name of the folder to fsevent_old. I was then able to run React without an issue.

@mattrafalko

This comment has been minimized.

Copy link

commented Jun 10, 2019

I was able to resolve the issue with npm i -S fsevents.
I did not have any luck with @Shahor 's fix, and I didn't try any solutions involving yarn as I don't use yarn.

@vjpr

This comment has been minimized.

Copy link

commented Jun 13, 2019

So chokidar@2 seems broken as pointed out in this comment.

We should use chokidar@3.

From OP's stack trace we can't see which package uses chokidar because its run async from a callback.

Go to the earliest line we have in the stack trace, and place a console.trace() outside the callback. For me it was fsevents-handler.js:333. This let me see that it was watchpack that depended on chokidar@2.

When using pnpm in a monorepo...

In a pnpm monorepo we can search for usages like so: pnpm ls --depth=100 --filter my-package chokidar, which also showed me:

└─┬ react-scripts@3.0.1
  ├─┬ react-dev-utils@9.0.1
  │ └─┬ fork-ts-checker-webpack-plugin@1.1.1
  │   └── chokidar@2.1.6
  ├─┬ webpack@4.29.6_webpack@4.29.6
  │ └─┬ watchpack@1.6.0
  │   └── chokidar@3.0.1
  └─┬ webpack-dev-server@3.2.1_webpack@4.29.6
    └── chokidar@3.0.1

Using pnpm and pnpmfile.js it can be patched like so:

if (pkg.name === 'watchpack') {
  pkg.dependencies['chokidar'] = '3.0.1'
}
// and webpack-dev-server and fork-ts...

Then trigger a reinstall like so:

pnpm up --depth=100 --filter my-package

This fixed it for me.

@yalegria

This comment has been minimized.

Copy link

commented Jul 10, 2019

Installing yarn fixed it for me.

@frknasir

This comment has been minimized.

Copy link

commented Jul 18, 2019

I was able to resolve the issue with npm i -S fsevents.
I did not have any luck with @Shahor 's fix, and I didn't try any solutions involving yarn as I don't use yarn.

This did it for me. Thanks!!!

@mvermadev

This comment has been minimized.

Copy link

commented Jul 22, 2019

I had the same issue. How did you solve it?

Updated 22:30
This worked for me:

  1. I deleted my react app because I realized I did not have yarn installed.
  2. So I installed yarn.
  3. Then, again I did npx create-react-app my-app, and it worked. The issue disappeared.

Other things I did:

  • Installed node globally
  • Cleared the node caché

Worked for me, thanks mate!

Yes, Its work but unfortunately we did not found the actual error to resolve that permanently.

@rathnak

This comment has been minimized.

Copy link

commented Jul 28, 2019

It may seem weird, but I was able to get it working after running:
$sudo npm install npm@latest -g

@Parthan-Sachin

This comment has been minimized.

Copy link

commented Aug 1, 2019

I also had the same issue though am using MacOS the issue is kind of bug. I solved this issue by repeatedly running the commands,

  • sudo npm cache clean --force
  • sudo npm uninstall
  • sudo npm install

One time it did not worked but when I repeatedly cleaned the cache and after uninstalling npm, reinstalled npm, the error went off. Am using Angular 8 and this issue is common

@ronanmockett

This comment has been minimized.

Copy link

commented Aug 3, 2019

I had the same problem because I created new project using sudo what caused permission conflict.
$ sudo npx create-react-app my-app // Did not work

$ npx create-react-app my-app
$ cd my-app && npm start // Work like a charm`

I hope this help someone to resolve this issue.

Thank you this worked for me!

@mvermadev

This comment has been minimized.

Copy link

commented Aug 4, 2019

@marcosaimola

This comment has been minimized.

Copy link

commented Aug 5, 2019

You need to install the yarn before creating your app

sudo npm i -g yarn
npx create-react-app my-app
cd my-app
npm start

It have worked for me. ;)

@mvermadev

This comment has been minimized.

Copy link

commented Aug 5, 2019

@Luke-Markham

This comment has been minimized.

Copy link

commented Aug 6, 2019

sudo n 10.16.0
npx create-react-app my-app
cd my-app
npm install
npm start

my fix above

@mvermadev

This comment has been minimized.

Copy link

commented Aug 6, 2019

@sanalpanicker

This comment has been minimized.

Copy link

commented Aug 6, 2019

use npx create-react-app my-app --use-npm

@lucassacheto

This comment has been minimized.

Copy link

commented Aug 10, 2019

This worked for me:

npm audit fix --force

@jasonfb

This comment has been minimized.

Copy link

commented Aug 10, 2019

I had this problem on macOS 10.13 too while using yarn, on a brand new create-react-app. I do not have a node version set in my package.json file, but for reference here is the rest of my package.json

{
  "name": "star-ratings-basic",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-scripts": "3.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

this happened to me while using NVM (node version manager) and had these versions of node & npm active respectively

$ npm -v
node 6.10.2
$ node -v
v12.8.0

deleting my yarn.lock file & deleting the node_modules folder and then running yarn worked immediately.

interestingly, I was able to get a diff on the regenerated yarn lock file compared to the old one. as seen by git diff ( note minus and plus symbols )

-"@babel/code-frame@7.5.5", "@babel/code-frame@^7.5.5":
+"@babel/code-frame@7.5.5", "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5":
   version "7.5.5"
   resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d"
   integrity sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==
   dependencies:
     "@babel/highlight" "^7.0.0"
 
-"@babel/code-frame@^7.0.0":
-  version "7.0.0"
-  resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8"
-  integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==
-  dependencies:
-    "@babel/highlight" "^7.0.0"
-
 "@babel/core@7.5.5", "@babel/core@^7.1.0", "@babel/core@^7.4.5":
   version "7.5.5"
   resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.5.5.tgz#17b2686ef0d6bc58f963dddd68ab669755582c30"
@@ -36,17 +29,6 @@
     semver "^5.4.1"
     source-map "^0.5.0"
 
-"@babel/generator@^7.1.3":
-  version "7.1.3"
-  resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.1.3.tgz#2103ec9c42d9bdad9190a6ad5ff2d456fd7b8673"
-  integrity sha512-ZoCZGcfIJFJuZBqxcY9OjC1KW2lWK64qrX1o4UYL3yshVhwKFYgzpWZ0vvtGMNJdTlvkw0W+HR1VnYN8q3QPFQ==
-  dependencies:
-    "@babel/types" "^7.1.3"
-    jsesc "^2.5.1"
:

@mvermadev

This comment has been minimized.

Copy link

commented Aug 11, 2019

@jasonfb

This comment has been minimized.

Copy link

commented Aug 11, 2019

seems like I can reproduce it…

$ node -v
v12.8.0
$ npm -v
6.10.2
$ create-react-app test-app

(normal create-react-app output truncated)

$ yarn start

the server starts, it clears the console and then the app crashes with this. at the same time Chrome opens to 127.0.0.1:3000 but to a "This site can’t be reached" page as the server is crashed

Starting the development server...

/Users/jason/Work/LEARNING/React_JS/testapp/node_modules/chokidar/lib/fsevents-handler.js:28
  return (new fsevents(path)).on('fsevent', callback).start();
          ^

TypeError: fsevents is not a constructor
    at createFSEventsInstance (/Users/jason/Work/LEARNING/React_JS/testapp/node_modules/chokidar/lib/fsevents-handler.js:28:11)
    at setFSEventsListener (/Users/jason/Work/LEARNING/React_JS/testapp/node_modules/chokidar/lib/fsevents-handler.js:82:16)
    at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/jason/Work/LEARNING/React_JS/testapp/node_modules/chokidar/lib/fsevents-handler.js:252:16)
    at FSWatcher.<anonymous> (/Users/jason/Work/LEARNING/React_JS/testapp/node_modules/chokidar/lib/fsevents-handler.js:386:25)
    at LOOP (fs.js:1576:14)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ 

I'm using nvm, and I have node 12.8.0 activated. should I do something else to update npm or node in my system? I'm not sure I understand if there's any steps I'm missing when you say "First update your nodejs in your system". am I not using the latest versions?

@jasonfb

This comment has been minimized.

Copy link

commented Aug 11, 2019

it appears to do this for me on every create-react-app I make

@mvermadev

This comment has been minimized.

Copy link

commented Aug 11, 2019

@Yanzoo88

This comment has been minimized.

Copy link

commented Aug 12, 2019

I had the same problem because I created new project using sudo what caused permission conflict.
$ sudo npx create-react-app my-app // Did not work

$ npx create-react-app my-app
$ cd my-app && npm start // Work like a charm`

I hope this help someone to resolve this issue.

This worked for me too :) Cheers!

@jasonfb

This comment has been minimized.

Copy link

commented Aug 14, 2019

hmm sudo apt update does not work for me

$ sudo apt update
 Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/apt" (-1)
@jasonfb

This comment has been minimized.

Copy link

commented Aug 14, 2019

incidentally I am on mac OS 10.13.6 using Xcode 9.4.1 with gcc clang version clang-902.0.39.2

I wonder if there's a way to blow away my yarn binary to clear the problem?

@jasonfb

This comment has been minimized.

Copy link

commented Aug 14, 2019

some people on the reactiflux Discord channel are recommending downgrading to Node 11 until the issue is mitigated.

@djayri

This comment has been minimized.

Copy link

commented Aug 17, 2019

This worked for me:

npm audit fix --force

thanks mate. this worked for me

@erickacevedor

This comment has been minimized.

Copy link

commented Aug 18, 2019

You need to install the yarn before creating your app

sudo npm i -g yarn
npx create-react-app my-app
cd my-app
npm start

It have worked for me. ;)

This indeed works. I struggle making my first react app to work at first, but eventually installing yarn (and use it after that) make it work, it really do the trick

@DominicTobias

This comment has been minimized.

Copy link
Contributor Author

commented Aug 23, 2019

I no longer get this issue, tested with Node 12.7 and 12.9 using either NPM or Yarn. Thinking of closing this soon as it seems to have been resolved.

@barunprasad

This comment has been minimized.

Copy link

commented Aug 27, 2019

rm -rf node_modules
rm -f yarn.lock 
yarn

Solve the issue

This worked for me. I had Node version: 12.8.0 on a mac

@lock lock bot locked and limited conversation to collaborators Sep 6, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.