8

I've been trying use create react app but when I go to create it in the terminal i get this 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! 
npm ERR! See /Users/chrisheibel/.npm/eresolve-report.txt for a full report.

npm ERR!`

I've tried using --legacy-peer-deps and --force with no luck. It will create the app but npm start does not work. Once i've created it i've tried to install/update npm and node again with no luck. I've also uninstalled node and npm globally on my computer and reinstalled with no luck, as well as turning react and react-dom in the created app to version 17 instead of 18 but had no luck there.

I'm at a bit of a loss on this one as create react app has always worked on my computer before. But maybe you guys might know if i'm missing something here and that's why I can't run npm start/ am getting all these errors.

4 Answers 4

7

The error message is telling you what the issue is. The important parts are:

Found: [email protected]

and

peer react@"<18.0.0" from @testing-library/[email protected]

So @testing-library/[email protected] is only compatible with react <18 and you have added react 18, which breaks this rule. Upgrade @testing-library/react to a compatible version or downgrade react to < 18.

the latest version of @testing-library/react is 13. so you should likely have something like

"@testing-library/react": "^13.0.0"

in your package.json

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

Comments

1

It might work for install same version for both

npm install react@18 react-dom@18

1 Comment

Works with npm create-react-app version 5.0.1. Installing 17 version failed. Thank you.
0

Still having problems with create-react-app ? Use Vite instead;

sudo npm install -g create-vite
npm create vite@latest my_app --template react

Comments

-1

I'd check your version of create-react-app

create-react-app --version

Mine says 5.0.0.

The documentation says to uninstall create-react-app and run it using npx. Running with npx will install the latest version:

npm uninstall -g create-react-app
npx create-react-app your-app-name

When I run create-react-app today I get a react v18 app. In some cases I've had to downgrade it to v17. I've done this as follows:

npm uninstall react react-dom
npm install react@!7 react-dom@17

3 Comments

Well yes, downgrading react will fix the issue, but you can't just not upgrade because of a dependency issue.
The question specifically asks how to downgrade to v17 from v18. It is necessary to do this in order to use many packages right now.
No, the questions says they've tried downgrading with no luck. as well as turning react and react-dom in the created app to version 17 instead of 18 but had no luck there. The conflicting library has a compatible upgrade, so the solution is to upgrade that.

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.