Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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


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)

does anyone have facing same issue if yes then whats the solution ?

like image 248
Murtaza Hussain Avatar asked Apr 11 '21 07:04

Murtaza Hussain


People also ask

How do I update Chokidar?

Update chokidar by doing rm -rf node_modules package-lock. json yarn. lock && npm install , or update your dependency that uses chokidar.

What is Chokidar NPM?

Chokidar is a fast open-source file watcher for node. js. You give it a bunch of files, it watches them for changes and notifies you every time an old file is edited; or a new file is created. I've created it in 2012, to mitigate differences between node file watching APIs such as fs.


3 Answers

I got the same error when using [email protected] and was able to fix it by either downgrading to [email protected] or by running npm update --force command.

like image 125
Samuli Asmala Avatar answered Oct 18 '22 04:10

Samuli Asmala


Try:

npm i --legacy-peer-deps

For more information have a look on:

https://github.com/facebook/create-react-app/issues/10811

like image 3
Sujan Dahal Avatar answered Oct 18 '22 05:10

Sujan Dahal


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

here is the detailed reasoning of why it may cause:

What does npm install --legacy-peer-deps do exactly? When is it recommended / What's a potential use case?

like image 1
Murtaza Hussain Avatar answered Oct 18 '22 04:10

Murtaza Hussain