Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error : unable to resolve dependency tree

I’m working on a React project and I wanted to install react testing library using the command npm install --save-dev @testing-library/react. But unfortunately, I’m getting the following error. enter image description here

Here is my package.json file :

{
  "description": "Sample Shopping Cart to Explore using RTK",
  "version": "0.2.0",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "serve": "vite preview"
  },
  "dependencies": {
    "@reduxjs/toolkit": "^1.6.0",
    "classnames": "^2.3.1",
    "peers": "^0.1.0",
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-redux": "^7.2.4",
    "react-router-dom": "^5.2.0"
  },
  "devDependencies": {
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@types/react-router-dom": "^5.1.7",
    "@vitejs/plugin-react-refresh": "^1.3.1",
    "jest": "^29.4.2",
    "typescript": "^4.1.2",
    "vite": "^2.3.5"
  }
}

My node version is v18.14.0. Can someone help me in this issue?. Thanks in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like @testing-library/react found React 17 installed but prefers React 18. You can either upgrade to 18, which is not possible for some at the moment.

In that case, try simply using @testing-library/react@12.

They dropped support for React 17 in their v13.0.0 release and announced a breaking change:

https://github.com/testing-library/react-testing-library/releases/tag/v13.0.0

The downside to using @testing-library/react@12 is you will need to reference old documentation because you won’t have the benefit of v13+ releases.

Hope this helps!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading