0

I am newbie to react technology and I faced an error while creating a react app:

Initialized a git repository.

Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: frontend@0.1.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/react@12.1.5
npm ERR! node_modules/@testing-library/react
npm ERR!   @testing-library/react@"^12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\nahee\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nahee\AppData\Local\npm-cache\_logs\2022-04-12T12_46_13_743Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^12.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

As a result I am unable to start the app

For this I used npm uninstall -g create-react-app and npm cache verify commands to clear the error even though I am unable to resolve it.

For creating a react app I used

npx create-react-app frontend

What is my issue?

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
  • Does this answer your question? [create-react-app dependency version issues with React 18](https://stackoverflow.com/questions/71835697/create-react-app-dependency-version-issues-with-react-18) – Bergi Apr 12 '22 at 23:09
  • I used this command 'npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^12.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` and it worked for me. – Shaik Naheeda parveen Apr 13 '22 at 06:34

1 Answers1

0

I think there is an issue with react-testing-library. Based on the error message, it supports only React < 18 version. You can read it here.

For an alternative solutions, you can manually add those to your project like how they mentioned on the error log(which I did for myself)

npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^12.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

Or you can check this too. create-react-app dependency version issues with React 18

mc-user
  • 1,769
  • 4
  • 14
  • 25