2

So I'm trying to learn React, followed the instruction on https://reactjs.org/docs/create-a-new-react-app.html. Specifically, I'm using Create React App, and happened to bump into an error:

Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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/[email protected]
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!

From what I'm seeing here, the Testing library required that the installed React version be less than 18.0.0, but Create React App just automatically install the latest React version, leading to the error.

How do I resolve this? As said earlier, I'm a complete newbie, so any help is much appreciated.

1 Answer 1

4

Until this is fixed for now you can delete the node_modules folder and package-lock.json.

Next, open package.json and change "react": "^18.0.0" & "react-dom": "^18.0.0" to an earlier version e.g. "react": "^17.0.2" & "react-dom": "^17.0.2".

Finally, can run npm install

Sign up to request clarification or add additional context in comments.

6 Comments

Until this is fixed for now you can delete the "node_modules" folder and "package-lock.json". Next, open "package.json" and change "react": "^18.0.0" & "react-dom": "^18.0.0" to an earlier version e.g. "react": "^17.0.2" & "react-dom": "^17.0.2". Finally, can run "npm install". Share Edit Follow answered 1 hour ago user avatar Gavriel
Thank you. I guess that would have to do for now. Hopefully this issue would get resolved soon.
You have to enter the app folder BEFORE running npm install, (cd my-app).
I get a similar error. I changed my react and react-dom versions in my package.json from 17.0.2 to ^17.0.2 and indeed that resolved the error! @liam, are you saying this is a known issue? If so, do you know have a link to where it was reported?
@Woodchuck The problem has now been fixed, github.com/facebook/create-react-app/issues/12279
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.