'setting up a React Sandbox for beginners...dependencies error?
Basically spent half a day trying to set this up with no luck.
I have been using npx create-react-app like in this video but I receive the following:
Installing template dependencies using npm...
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/[email protected]
broken) dependency resolution.
npm ERR! the root project
I have seen here create-react-app dependency version issues with React 18 that there may be dependency issues. I have tried the following fix from the post:
- delete both node_modules and package-lock.json
- run
npm i web-vitals --save-dev - run
npm install - and then you can use
npm run buildandnpm startagain
But I am still receiving error messages. I also uninstalled node.js and installed v16.14.2.
Any help would be really appreciated...
Many thanks
Solution 1:[1]
It seems that you're already in a folder that have package.json file which messes things up with dependencies.
Try to begin again in a new fresh folder.
The second thing you can try is to upgrade @testing-library/react by using this command :
npm install @testing-library/react@latest
Why ?
As you can see on you dependencies you have a React version > 18 that's what "^" mean in react@"^18.0.0"
BUT @testing-library is requiering a reatc version that is strictly inferior to 18.0.0 that's what mean the "<" in react@"<18.0.0"
More on dependencies semantics : HERE
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
