You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
With a new version 12.1.5 of "@testing-library/react" running "npx create-react-app" fails with an ERESOLVE issue #12278
If you run "npx create-react-app Project-Name" after version 12.1.5 of @testing-library/react was released if will fail because current "cra-template" has "@testing-library/react": "^12.0.0" in its dependencies template for a new project. Version 12.1.5 of @testing-library/react requires "react": "<18.0.0" in its peer dependencies. That creates a conflict of dependencies.
Error report:
While resolving: test2@0.1.0
Found: react@18.0.0
node_modules/react
react@"^18.0.0" from the root project
Could not resolve dependency:
peer react@"<18.0.0" from @testing-library/react@12.1.5
node_modules/@testing-library/react
@testing-library/react@"^12.0.0" from the root project
Closed the issue because the problem was in npm cache of my computer.
The dependencies list was already updated three days ago and now it contains ^13.0.0 of @testing-library/react
Sorry, didn't check everything. The problem is still active for me. I'm reopening it.
It will be fixed in version 5.0.1 (pull request is already approved), but at this moment it doesn't work.
npx create-react-app my-app (let the build fail)
Delete the node_modules directory
Delete the package-json.lock file
Open package.json and change it to the following:
It will be resolved in the next version on CRA, there's already accepted pull request for it (mentioned before).
I closed an issue because I can't see a way to solve this issue permanently until the new version is published.
Temporary solutions are here for anybody to use.
npx create-react-app my-app (let the build fail) Delete the node_modules directory Delete the package-json.lock file Open package.json and change it to the following:
create-react-app is not updating index.js as per the new react V18
so you need to modify index.js file as follow
import React from 'react';
import {createRoot} from 'react-dom/client';
import './index.css';
import App from './App';
// import reportWebVitals from './reportWebVitals';
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
// reportWebVitals();
Thank you for fixing the issue. I thought something was with my computer, so I tried on Windows, Linux and Mac all with the same issue. Today everything worked great. Thank you for your work. A deep bow from me!
Activity
wsy commentedon Apr 12, 2022
I came across this problem, too!
wsy commentedon Apr 12, 2022
Why you closed this? @stas-litv Did you solve this problem?
stas-litv commentedon Apr 12, 2022
Closed the issue because the problem was in npm cache of my computer.
The dependencies list was already updated three days ago and now it contains ^13.0.0 of @testing-library/react
DailyDisco commentedon Apr 12, 2022
How did you fix the issue? I have the same problem. Thanks in advance.
stas-litv commentedon Apr 12, 2022
Sorry, didn't check everything. The problem is still active for me. I'm reopening it.
It will be fixed in version 5.0.1 (pull request is already approved), but at this moment it doesn't work.
DailyDisco commentedon Apr 12, 2022
Ah okay, so we just need to wait for an update?
stas-litv commentedon Apr 12, 2022
Looks like we need to wait, I don't know for sure. That's why I reopened the issue.
I'm waiting for someone to comment it.
Pull request that fixes it: #12223
LagunaElectric commentedon Apr 12, 2022
I'm also experiencing this issue.
alaninnovates commentedon Apr 12, 2022
This is happening to me too.
moaazassali commentedon Apr 12, 2022
Same issue here
wsy commentedon Apr 12, 2022
CRA 5.0.0 was released many months ago. I wonder why they did not notice this many months ago?
6 remaining items
dougmellon commentedon Apr 12, 2022
Temporary workaround:
npx create-react-app my-app (let the build fail)
Delete the node_modules directory
Delete the package-json.lock file
Open package.json and change it to the following:
Delete reportWebVitals.js
Remove
import reportWebVitals from './reportWebVitals';from index.jsRemove
reportWebVitals();from the bottom of index.jsRe-install with npm install.
viteshbava commentedon Apr 12, 2022
@stas-litv is this closed because it has been resolved?
stas-litv commentedon Apr 12, 2022
It will be resolved in the next version on CRA, there's already accepted pull request for it (mentioned before).
I closed an issue because I can't see a way to solve this issue permanently until the new version is published.
Temporary solutions are here for anybody to use.
viteshbava commentedon Apr 12, 2022
@stas-litv I see - thank you!
danielru15 commentedon Apr 12, 2022
hola , en un grupo de facebook un usuario me compartio esta solucion:
abran el proyecto en visual studio y en el index.js remplazarlo por esto:
import React from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App';
const container = document.getElementById('root');
const root = createRoot(container);
root.render(
<React.StrictMode>
</React.StrictMode>,
);
luego puedes ejecutar npm start sin problemas
gannicus4431 commentedon Apr 12, 2022
Hi, may i know what do you re-install with npm install? Thank you so much.
dhruv-panchal211 commentedon Apr 12, 2022
I found the solution.
create-react-app is not updating index.js as per the new react V18
so you need to modify index.js file as follow
import React from 'react';
import {createRoot} from 'react-dom/client';
import './index.css';
import App from './App';
// import reportWebVitals from './reportWebVitals';
const container = document.getElementById('root');
const root = createRoot(container)
root.render(
)
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
// reportWebVitals();
mwskwong commentedon Apr 12, 2022
Workaround
Create a project using
npm initinsteadEdit
Just in case people are hesitant to do so, it is a documented way to bootstrap CRA projects. THe only thing added is
--legacy-peer-deps.JayceDugan commentedon Apr 12, 2022
+1 for @mwskwong here, worked well.
Also in case anyone's just looking to get a project running in the interim,
yarn create react-app my-appis still working without--legacy-peer-deps.ottokruse commentedon Apr 12, 2022
Another work around, that allows me to go ahead with React 18 and the TypeScript CRA template:
mustafabin commentedon Apr 12, 2022
running
npm i web-vitals --save-devworked for megannicus4431 commentedon Apr 12, 2022
Using
npm initas suggested by mwskwong.From my understanding they pretty much do the same thing except version control.
Compare npx and npm:
https://stackoverflow.com/questions/50605219/difference-between-npx-and-npm
welschmoor commentedon Apr 17, 2022
Thank you for fixing the issue. I thought something was with my computer, so I tried on Windows, Linux and Mac all with the same issue. Today everything worked great. Thank you for your work. A deep bow from me!