-
Notifications
You must be signed in to change notification settings - Fork 47.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[React 19] Error when use create-react-app #32016
Comments
The current version of create-react-app generates a package.json file with React 19, which causes a dependency conflict since @testing-library/[email protected] only supports React 18. Use the following command to make sure React 18 and is installed: npx create-react-app my-app --template cra-template or you can manually adjust the package.json file as: "dependencies": { |
The issue occurs because the npx create-react-app command is generating a package.json file that uses React version 19, while @testing-library/[email protected] explicitly supports only React 18. This version mismatch creates a dependency conflict, resulting in the ERESOLVE Unable to resolve dependency tree error. solution:
npx create-react-app . ps: this is only temporary fix and not ideal for long-term stability
open package.json and change the React version reinstall dependencies
bash: |
what if we use typescript |
PS D:\react-type> npx create-react-app my-app-react --template typescript --use-npm --legacy-peer-deps Creating a new React app in D:\react-type\my-app-react. Installing packages. This might take a couple of minutes. added 1323 packages in 3m 267 packages are looking for funding Initialized a git repository. Installing template dependencies using npm... .........but again i got same error |
that's because you are using CRA again.... try this code: then you will be aksed to chose the framework and variant....chose react (or any other framework that you like) and select TypeScript as a variant after choosing the framework |
For react: chiragjha1 You may need to install: npm install web-vitals after downgrading to React 18 |
please assign this issue i want to work |
The cleanest solution is to downgrade to React 18 since the @testing-library/react version you're using (13.4.0) only supports React 18. Alternatively, you can try using --force or --legacy-peer-deps to bypass the conflict, but these might lead to compatibility issues later. If you're set on using React 19, be prepared to face potential issues with dependencies that are not yet compatible. |
No matter which method mentioned above is used, an error will eventually occur. (Except using Vite, of course) Right now,create-react-app needs to be downgraded to use react 18. |
i will use vite which will give you the smooth experience |
Summary
When you try to run the command 'npx create-react-app .' and proceed to install the dependencies with npm it returns an error code ERESOLVE Unable to resolve dependency tree as it generates the package.json with React version 19 but @testing-library/[email protected] is compatible exclusively with React 18.
Screenshots
The text was updated successfully, but these errors were encountered: