create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Could not resolve dependency: peer react@"^18.0.0" from @testing-library/[email protected]

Open wanesoft opened this issue 11 months ago • 21 comments

node --version
v22.13.0
npx --version
10.9.2
npx create-react-app test-use-state

Creating a new React app in /root/test-use-state.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


added 1323 packages in 25s

267 packages are looking for funding
  run `npm fund` for details

Initialized a git repository.

Installing template dependencies using npm...
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error   react@"^19.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^18.0.0" from @testing-library/[email protected]
npm error node_modules/@testing-library/react
npm error   @testing-library/react@"^13.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /root/.npm/_logs/2025-01-16T15_24_57_774Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-01-16T15_24_57_774Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed

wanesoft avatar Jan 16 '25 15:01 wanesoft

bumping this

6lyxt avatar Jan 17 '25 07:01 6lyxt

:bump:

stackcv avatar Jan 20 '25 17:01 stackcv

bump %)

william-aqn avatar Jan 21 '25 15:01 william-aqn

bump %)

origicom avatar Jan 21 '25 15:01 origicom

retweet

sabrina-stangler avatar Jan 22 '25 17:01 sabrina-stangler

bump

MonteMango avatar Jan 22 '25 20:01 MonteMango

bump

fightingsleep avatar Jan 22 '25 20:01 fightingsleep

bump

TimZaman avatar Jan 22 '25 21:01 TimZaman

Ah, so currently the happy path of create-react-app doesn't even work... bummer

funkjunky avatar Jan 22 '25 23:01 funkjunky

bump

using windows surface pro on ARM

heyitsbryanm avatar Jan 23 '25 17:01 heyitsbryanm

bump

manutrix avatar Jan 23 '25 22:01 manutrix

I'm having this same issue! A band-aid solution should work for now since this thread looks new, but because it looks like there haven't been any non-documentation changes in over a year, it looks like this problem is the result of the development team having abandoned this project. If you want to continue, here's the full set of commands I used to clean up the errors for a successful run of a new React application.

Just note, this is a temporary solution, in that the create-react-app repo has had nothing but documentation changes since August 2023 (with the last build release being from 2022), so while there has been no official deprecation of this tool, this issue indicates that create-react-app is rotting. The below commands will clean up the current issues with new projects, but expect this tool to continue to show signs of its abandonment.

npx create-react-app my-app

The above generates the same errors we're all observing. The below commands are the cleanup.

cd my-app
npm install --save-dev @testing-library/react@latest
npm install web-vitals
npm start

Upon npm start, it should say it compiled successfully, and the app should run for you without an error popping up.

Hernandezn avatar Jan 23 '25 23:01 Hernandezn

create-react-app is deprecated. You must use Vite to initialize a project.

https://medium.com/@miahossain8888/how-to-create-a-react-app-with-vite-571883b100ef

OndrejPlecak avatar Jan 24 '25 19:01 OndrejPlecak

I've been playing with different AI generators and they provided Vitae as a faster development process and it didn't throw an error. npm create vite@latest your-app -- --template react-ts cd your-app npm install npm run dev

davidt4444 avatar Jan 28 '25 05:01 davidt4444

bump

mbrunel-H avatar Feb 03 '25 10:02 mbrunel-H

create-react-app is deprecated. You must use Vite to initialize a project.

You can still use create-react-app if you want to.

For me, the following works:

npx create-react-app test-cra # n.b. this step will report failure
cd test-cra
yarn
yarn add web-vitals
yarn start

alxndrsn avatar Feb 03 '25 10:02 alxndrsn

bump

coarsehorse avatar Feb 03 '25 12:02 coarsehorse

bump

stepan323446 avatar Feb 06 '25 06:02 stepan323446

The create-react-app README has been updated to indicate that this project is now deprecated. See #17003 which was merged January 28, 2025.

scifisamurai avatar Feb 08 '25 00:02 scifisamurai

You need to install one more package to make unit tests work (in addition to @Hernandezn answer)

npm install --save-dev @testing-library/jest-dom@latest
npm run test

VladyslavKurmaz avatar Feb 10 '25 09:02 VladyslavKurmaz

This worked for me and React is running perfectly fine. Thank you so much for the help @Hernandezn

npm install --save-dev @testing-library/react@latest

npm install web-vitals

satyendrasonwani avatar Feb 11 '25 17:02 satyendrasonwani