'Problem installing react@18 - why can I not install the package?

I can't install react@18 because i get the following error

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "current": {
    "name": "react",
    "version": "18.0.0",
    "whileInstalling": {
      "name": "cap",
      "version": "0.1.0",
      "path": "/Users/dheld/pollopi/cap"
    },
    "location": "node_modules/react",
    "isWorkspace": false,
    "dependents": [
      {
        "type": "prod",
        "name": "react",
        "spec": "^18.0.0",
        "from": {
          "location": "/Users/dheld/pollopi/cap"
        }
      }
    ]
  },
  "currentEdge": {
    "type": "prod",
    "name": "react",
    "spec": "^18.0.0",
    "from": {
      "location": "/Users/dheld/pollopi/cap"
    }
  },
  "edge": {
    "type": "peer",
    "name": "react",
    "spec": "<18.0.0",
    "error": "INVALID",
    "from": {
      "name": "@testing-library/react",
      "version": "12.1.5",
      "whileInstalling": {
        "name": "cap",
        "version": "0.1.0",
        "path": "/Users/dheld/pollopi/cap"
      },
      "location": "node_modules/@testing-library/react",
      "isWorkspace": false,
      "dependents": [
        {
          "type": "prod",
          "name": "@testing-library/react",
          "spec": "^12.0.0",
          "from": {
            "location": "/Users/dheld/pollopi/cap"
          }
        }
      ]
    }
  },
  "strictPeerDeps": false,
  "force": false
}

I already tried to install @testing-library/react globally and in the folder but both doesn't work

React 16 I can install without any problems

What you see in the code segment is the output of the file eresolve-report.txt

Maybe someone has a solution for :)

Thanks so much!!!



Solution 1:[1]

What I understand from the error message, is that the @testing-library/react package requires a React version prior to 18. So you cannot install React 18, at least while it's not supported by testing-library.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pablo R. Dinella