create-react-app: v3.0.0 with Node v12/NPM 6.9.0 gives "TypeError: fsevents is not a constructor"

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® Core™ 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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 22
  • Comments: 55 (3 by maintainers)

Commits related to this issue

Most upvoted comments

rm -rf node_modules
rm -f yarn.lock 
yarn

Solve the issue

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.

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é

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!

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);

FYI:

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

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.

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.

all my problems i’ve got is from fsevents why so terrible 😦

I fix this issue using this command npm install -g chokidar

"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 👍

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

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!

This worked for me:

npm audit fix --force

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. 😉

Hello Ronan, if you are using ‘npx’ to create react app then you didn’t need to add sudo command at the beginning. If you are using ‘npm’ then you need (if system want super user permission) to add at the beginning.

I hope you got it.

Regards, MANISH VERMA.

On Sat, 3 Aug 2019, 8:33 pm Ronan Mockett, notifications@github.com wrote:

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!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/create-react-app/issues/6891?email_source=notifications&email_token=AHTB43X5YKCKLDFEGOH4JFLQCWM3LA5CNFSM4HIIC3JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PP7UQ#issuecomment-517930962, or mute the thread https://github.com/notifications/unsubscribe-auth/AHTB43SWARCISEUSMDECNYTQCWM3LANCNFSM4HIIC3JA .

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!

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!!!

I agree with @mattrafalko, the npm i fsevents solution worked for me. I also made sure to run npm i react-scripts since I was having an issue with npm start

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.

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