Could not resolve dependency: peer react@"^18.0.0" from @testing-library/[email protected]
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
bumping this
:bump:
bump %)
bump %)
retweet
bump
bump
bump
Ah, so currently the happy path of create-react-app doesn't even work... bummer
bump
using windows surface pro on ARM
bump
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-appnpm install --save-dev @testing-library/react@latestnpm install web-vitalsnpm start
Upon npm start, it should say it compiled successfully, and the app should run for you without an error popping up.
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
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
bump
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
bump
bump
The create-react-app README has been updated to indicate that this project is now deprecated. See #17003 which was merged January 28, 2025.
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
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