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

Error: No version of chokidar is available. Tried chokidar@2 and chokidar@3. after upgrading npm to 7.*.* #10811

Open
m-nathani opened this issue Apr 11, 2021 · 26 comments

Comments

@m-nathani
Copy link

m-nathani commented Apr 11, 2021

Describe the bug

using ejected CRA , it compiles successfully and then it breaks showing below error.. it started happend when i updated npm to 7 from 6

Did you try recovering your dependencies?

i tried runnung npm npm cache verify && rm -rf node_modules/ && npm i but it did not worked

Environment

node: v14.16.0
npm: 7.9.0

OS: Linux (Ubuntu)
├── webpack-dev-server@3.11.0
├── webpack-manifest-plugin@2.2.0
├── webpack@4.44.2

Steps to reproduce

npm start

Expected behavior

should run the server succsessfully

Actual behavior

You can now view webrms in the browser.

  Local:            http://localhost:3001
  On Your Network:  http://192.168.0.160:3001

Note that the development build is not optimized.
To create a production build, use npm run build.

/home/murtaza/umai/webrms/node_modules/watchpack/lib/chokidar.js:17
throw new Error(
^

Error: No version of chokidar is available. Tried chokidar@2 and chokidar@3.
You could try to manually install any chokidar version.
chokidar@3: Error: Cannot find module 'chokidar'
Require stack:
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/chokidar.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/DirectoryWatcher.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/watcherManager.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/watchpack.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/node/NodeWatchFileSystem.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/webpack.js
- /home/murtaza/umai/webrms/scripts/start.js
chokidar@2: Error: Cannot find module 'watchpack-chokidar2'
Require stack:
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/chokidar.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/DirectoryWatcher.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/watcherManager.js
- /home/murtaza/umai/webrms/node_modules/watchpack/lib/watchpack.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/node/NodeWatchFileSystem.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js
- /home/murtaza/umai/webrms/node_modules/webpack/lib/webpack.js
- /home/murtaza/umai/webrms/scripts/start.js

    at Object.<anonymous> (/home/murtaza/umai/webrms/node_modules/watchpack/lib/chokidar.js:17:7)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/home/murtaza/umai/webrms/node_modules/watchpack/lib/DirectoryWatcher.js:9:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    ```
@FizzBuzz791
Copy link

OK, so this actually seems to be a Node issue, I was running 15.14 and running into this issue.

I've installed nvm and set it to use Node 12.22.1 (latest v12 at time of writing) and npm run start now works correctly.

This makes sense because the npm i message indicated that chokidar would not work on Node 14+.

It looks like the chokidar requirements comes from react-scripts->webpack-dev-server and unfortunately, they don't upgrade to chokidar v3 until webpack-dev-server v4, which is still in beta. So, I guess we're stuck with running CRA on Node 12 for now.

@marko-hologram
Copy link

OK, so this actually seems to be a Node issue, I was running 15.14 and running into this issue.

I've installed nvm and set it to use Node 12.22.1 (latest v12 at time of writing) and npm run start now works correctly.

This makes sense because the npm i message indicated that chokidar would not work on Node 14+.

It looks like the chokidar requirements comes from react-scripts->webpack-dev-server and unfortunately, they don't upgrade to chokidar v3 until webpack-dev-server v4, which is still in beta. So, I guess we're stuck with running CRA on Node 12 for now.

As far as I know, you should be able to use Node v14 so there is no need to downgrade all the way to v12. Node v14 (14.16.1) is current LTS release so it might be better to use it compared to v12.

@FizzBuzz791
Copy link

Yep, @marko-hologram - that's what I'm saying, 14+ isn't working, people (like OP & myself) are getting this error.

It's possibly also a Windows (myself) vs Mac/Unix issue... I've been hitting a lot of weird stuff lately trying to work on a multi-OS team.

@marko-hologram
Copy link

Yep, @marko-hologram - that's what I'm saying, 14+ isn't working, people (like OP & myself) are getting this error.

It's possibly also a Windows (myself) vs Mac/Unix issue... I've been hitting a lot of weird stuff lately trying to work on a multi-OS team.

Yeah, but I'm saying that v14 should be working and you don't need to downgrade all the way to v12. I tested on Windows only tho.

@m-nathani
Copy link
Author

m-nathani commented Apr 19, 2021

its something definitely wrong with npm 7.*.* .. i tried npm i --legacy-peer-deps and it worked for me...

however it shouldn't be like this and dependencies should handled in latest stable version..
also haven't tried removing node_modules and running npm i after it..

here is the detailed reasoning of why it may cause:
https://stackoverflow.com/questions/66239691/what-does-npm-install-legacy-peer-deps-do-exactly-when-is-it-recommended-wh/66620869#66620869

@MarkADurham
Copy link

MarkADurham commented Apr 29, 2021

I concur with @m-nathani . The issue is definitely at least partially related to npm 7.*.*. npm version 6.14.12 (Node version 14.16.1) does not have the problem for me, whereas npm version 7.11.1 (same version of Node) definitely does. It is also specifically a Windows issue.

@vinilopes91
Copy link

I concur with @m-nathani . The issue is definitely at least partially related to npm 7.*.*. npm version 6.14.12 (Node version 14.16.1) does not have the problem for me, whereas npm version 7.11.1 (same version of Node) definitely does. It is also specifically a Windows issue.

I'm using ubuntu 20.04 and npm v7.11.1 and I'm also having the same problem here.

@FizzBuzz791
Copy link

FizzBuzz791 commented Apr 30, 2021

Yeah, OK. My apologies, I thought it was node but it's because node installs npm alongside it.

Mac running Node 15.8 and NPM 7.5.3 works fine.
Ubuntu 18 running Node 15.9 and NPM 7.5.3 works fine.
Windows running Node 15.14 and NPM 7.7.6 shows this issue.
Windows running Node 15.14 and NPM 7.5.3 works fine! 🎉

@FizzBuzz791
Copy link

FizzBuzz791 commented Apr 30, 2021

Did some more testing, 7.5.4 works, 7.5.5+ fails.

@tfrijsewijk
Copy link

Same here. v14.16.1 with npm 7.5.4 works as well

@m-nathani
Copy link
Author

i am using 7.9.0 and its still not fixed, not sure if this is fixed in the latest version :/

@manuFL
Copy link

manuFL commented May 10, 2021

Same issue here... still no news? It's pretty critical I think...

@samuliasmala
Copy link

I can confirm that downgrading to npm@7.5.4 works.

It also started working with npm@7.13.0 after running npm update --force command. Looks like the reason is that after the command watchpack starts using v3 of chokidar:

Before update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  └─┬ webpack-dev-server@3.11.1
    └── chokidar@2.1.8

After update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  ├─┬ webpack-dev-server@3.11.1
  │ └── chokidar@2.1.8
  └─┬ webpack@4.44.2
    └─┬ watchpack@1.7.5
      ├── chokidar@3.5.1
      └─┬ watchpack-chokidar2@2.0.1
        └── chokidar@2.1.8

@shnigi
Copy link

shnigi commented May 28, 2021

Faced this issue when I updated from npm 6 to npm 7. I have not ejected. First I just installed chokidar as a dev dependency and then it works again with Node 14.16.0 npm 7.15.0

Edit: I just tried removing the dev dependency and then using "npm update chokidar" which updated my package-lock.json it now also works without having it as a dev dependency in the package.json

Why I have to do this: no idea.

@NoirVoider
Copy link

I can confirm that downgrading to works.npm@7.5.4

It also started working with after running command. Looks like the reason is that after the command starts using v3 of chokidar:npm@7.13.0``npm update --force``watchpack

Before update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  └─┬ webpack-dev-server@3.11.1
    └── chokidar@2.1.8

After update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  ├─┬ webpack-dev-server@3.11.1
  │ └── chokidar@2.1.8
  └─┬ webpack@4.44.2
    └─┬ watchpack@1.7.5
      ├── chokidar@3.5.1
      └─┬ watchpack-chokidar2@2.0.1
        └── chokidar@2.1.8

I can confirm that downgrading to works.npm@7.5.4

It also started working with after running command. Looks like the reason is that after the command starts using v3 of chokidar:npm@7.13.0``npm update --force``watchpack

Before update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  └─┬ webpack-dev-server@3.11.1
    └── chokidar@2.1.8

After update

$ npm ls chokidar
└─┬ react-scripts@4.0.3
  ├─┬ webpack-dev-server@3.11.1
  │ └── chokidar@2.1.8
  └─┬ webpack@4.44.2
    └─┬ watchpack@1.7.5
      ├── chokidar@3.5.1
      └─┬ watchpack-chokidar2@2.0.1
        └── chokidar@2.1.8

Thanks, that solved my problem. @samuliasmala

@brianwachira
Copy link

brianwachira commented Jun 9, 2021

Chockidar is a dependency inside webpack that takes care of hot reloads on save on development environment.

Chockidar 2 has problems with node v14+.

For me, npm update did update webpack to use chockidar 3 hence it finally started working.

@alex-drocks
Copy link

alex-drocks commented Jun 9, 2021

I had to create a brand new "create-react-app". Then copy all my sources in the new folder (and use yarn instead of npm) lol

@brianwachira
Copy link

I had to create a brand new "create-react-app". Then copy all my sources in the new folder (and use yarn instead of npm) lol

lol! @alex-drocks I was about to do the same then I thought I might encounter a more nagging error.

@steelkorbin
Copy link

Yep, npm 7.17.0 failed, yarn 1.22.10 worked. I actually prefer npm, sad day, but I have to roll with what works and spend my time debugging my own mess.

os: Pop!_OS 20.04 LTS (ubuntu 20.04 LTS)
node: v14.17.0
npm: 7.17.0
yarn: 1.22.10

"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",

Attempted to install chockidar with npm.
$ npm i chokidar
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: undefined
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64

Hope this helps, someone get around it and the npm or chockidar guys can fix it for the next release.

@steelkorbin
Copy link

Yay, npm is working again! Love the turnaround time on this guys!

node: v14.17.1 <- nice

@kushal9291
Copy link

I just installed chokidar as dev dependency and that works!

@arthurRuf
Copy link

I fixed it by using node v12.22.3 AND installing chokidar as a Dev Dependency
You can use nvm for that (https://github.com/nvm-sh/nvm)

nvm install 12.22.3
nvm use 12.22.3
npx create-react-app my-app
cd my-app
npm i -D chokidar
npm start

@Arhan7
Copy link

Arhan7 commented Jul 6, 2021

npm update --legacy-peer-deps
Worked for me, Chokidar 2 has problems with node 14v+. Upgrade to Chokidar 3 is necessary.

@Cornel777
Copy link

npm gives the warning itself:
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.

@michele-tolin
Copy link

I fixed it by using node v12.22.3 AND installing chokidar as a Dev Dependency You can use nvm for that (https://github.com/nvm-sh/nvm)

nvm install 12.22.3
nvm use 12.22.3
npx create-react-app my-app
cd my-app
npm i -D chokidar
npm start

It works for me using nvm with node v14.17.6 and npm 8.1.0
Thank you so much!!!!

@stale
Copy link

stale bot commented Jan 9, 2022

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.

@stale stale bot added the stale label Jan 9, 2022
jamesmoschou added a commit to criteria-labs/json-schema-ref-parser that referenced this issue Jan 3, 2023
Browser tests are failing in the CI environment with:
chokidar@3: Error: Cannot find module 'chokidar'

Don't know why but this thread might be relevant:
facebook/create-react-app#10811
philsturgeon pushed a commit to APIDevTools/json-schema-ref-parser that referenced this issue Jan 11, 2023
* Update package-lock.json file

* Fix broken tests in blank.spec.js

Blank binary file was not getting serialized as { type: "Buffer", data: [] }
because read(file) was returning a string instead of Buffer.

* Fix webpack error when running browser tests

Webpack 4 cannot parse module containing optional chaining operator.
See https://stackoverflow.com/questions/59972341/how-to-make-webpack-accept-optional-chaining-without-babel

* Fix tests in invalid.spec.js when running in Chrome

* Change statusCode to status

* Set the --openssl-legacy-provider flag when running browser tests

Recent versions of node upgraded to OpenSSL 3.0, which deprecated some
older crypto hashing algorithms including md4.

Webpack 4 hard codes the use of md4 ins some places, so we have to set this
flag until we can upgrade Webpack.

* Use isomorphic-fetch instead of node-fetch

Browser tests were failing as polyfill.js was loading a node package in a browser context.

* Increase minimum version of node to 17

This was when the --openssl-legacy-provider option was introduced.
Prior versions of node do not recognize this option.

* Add chokidar@3 as an explicit dev dependency

Browser tests are failing in the CI environment with:
chokidar@3: Error: Cannot find module 'chokidar'

Don't know why but this thread might be relevant:
facebook/create-react-app#10811

* Skip test assertion due to conflict on Windows

See also #286

* Explicitly define browsers and plugins in karma.conf.js

* Replace karma-edge-launcher with newer package
philsturgeon pushed a commit to APIDevTools/json-schema-ref-parser that referenced this issue Jan 20, 2023
* Update package-lock.json file

* Fix broken tests in blank.spec.js

Blank binary file was not getting serialized as { type: "Buffer", data: [] }
because read(file) was returning a string instead of Buffer.

* Fix webpack error when running browser tests

Webpack 4 cannot parse module containing optional chaining operator.
See https://stackoverflow.com/questions/59972341/how-to-make-webpack-accept-optional-chaining-without-babel

* Fix tests in invalid.spec.js when running in Chrome

* Change statusCode to status

* Set the --openssl-legacy-provider flag when running browser tests

Recent versions of node upgraded to OpenSSL 3.0, which deprecated some
older crypto hashing algorithms including md4.

Webpack 4 hard codes the use of md4 ins some places, so we have to set this
flag until we can upgrade Webpack.

* Use isomorphic-fetch instead of node-fetch

Browser tests were failing as polyfill.js was loading a node package in a browser context.

* Increase minimum version of node to 17

This was when the --openssl-legacy-provider option was introduced.
Prior versions of node do not recognize this option.

* Add chokidar@3 as an explicit dev dependency

Browser tests are failing in the CI environment with:
chokidar@3: Error: Cannot find module 'chokidar'

Don't know why but this thread might be relevant:
facebook/create-react-app#10811

* Skip test assertion due to conflict on Windows

See also #286

* Explicitly define browsers and plugins in karma.conf.js

* Replace karma-edge-launcher with newer package

* Increase default timeout of async tests

* Change package type to module

* Change require/module.exports to import/export in source files

* Delete "use strict" directives from source code

* Update tests to ES modules

* Re-export $RefParser methods as standalone functions

Preserve backwards compatibility

* Make karma config file a .cjs file

Fixes “require() of ES Module …/config.js not supported” error

* Avoid top-level await in path.js

The current configuration of karma uses Webpack 4, which can't parse
modules with top-level await.

* Revert back to __dirname for browser tests

Karma configuration needs to upgrade to Webpack 5 in order to use import.meta.url

* Fix lint issues

* Disable code coverage in CI for now

* Revert "Disable code coverage in CI for now"

This reverts commit f571f0a.

* Replace nyc with c8 to work with ES modules

* Implement a dual CommonJS/ES module package.json

* Hack to allow $RefParser to be imported from require() without .default property

Without this hack, you would have to do this:

const $RefParser = require("@apidevtools/json-schema-ref-parser).default;

Now you can do this:

const $RefParser = require("@apidevtools/json-schema-ref-parser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests