testing-library/react-testing-library

Upgrade to React 19, have multiple errors when create a new project

Closed this issue ยท 2 comments

When create a new project says:

npx create-react-app app

Creating a new React app in /.../app.

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


added 1319 packages in 8s

264 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: app@0.1.0
npm error Found: react@19.0.0
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/react@13.4.0
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.

The main react script for create a new project use the @testing-library/react using a old version an cause a conflict with the main package.

Please, upgrade the react package from 18 to 19.

For more information see the apocalypse post from react scripts repository:

Symilar issue 2 years ago when react upgrade to 18:

Please be more careful with the versions so that the react project builder doesn't break every time they are updated.

Hi @yhojann-cl.. This should probably be updated in CRA but AFAIK it is deprecated so I'm not sure they'll accept a PR.
I'll issue something there. I'm resolving this issue as it's not related to RTL and better be handled in CRA repo.

I've created facebook/create-react-app#13738, I'll work with the team to hopefully push this.