node.jsnpmyarn-v2

Why is Yarn trying to install 1.0.0 of a package when my package.json references ^0.22.0?


Here's my package.json:

{
  "scripts": {
    "examples": "docusaurus-examples",
    "start": "docusaurus-start",
    "build": "docusaurus-build",
    "publish-gh-pages": "docusaurus-publish",
    "write-translations": "docusaurus-write-translations",
    "version": "docusaurus-version",
    "rename-version": "docusaurus-rename-version"
  },
  "devDependencies": {
    "docusaurus": "^1.14.7",
    "cheerio": "^0.22.0"
  },
  "dependencies": {
    "react-treebeard": "^3.2.4"
  }
}

When I do yarn install I get this error:

error cheerio@1.0.0: The engine "node" is incompatible with this module. Expected version ">=18.17". Got "16.20.2"
error Found incompatible module.

That makes sense - I'm running Node.js 16.20.2 and per the release notes Cheerio 1.0.0 was released a few day ago and bumped the minimum required version Node.js.

Ideally, I'd upgrade the version of Node.js that I'm running, but I got errors when I did that and then did yarn build.

But why is yarn install trying to install Cheerio 1.0.0 when I'm clearly telling it to install 0.22.0? I tried ^0.22.0, ~0.22.0 and 0.22.0.

Maybe one of Docusaurus's dependencies is requiring Cheerio 1.0.0 but, if that were the case, then shouldn't I be getting some sort of "incompatible requirements" error instead of what I am getting?


Solution

  • in packages.json file add this in your existing resolution and devDependencies

     "resolutions":{
        "cheerio": "<1.0.0"
    }
    and--
     "devDependencies":{
        "cheerio": "<1.0.0"
    }