0

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: testfile@0.1.0
npm ERR! Found: react@18.0.0
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/react@12.1.5
 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 build and npm start again

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

Felix Geenen
  • 2,465
  • 1
  • 28
  • 37
poeticider
  • 11
  • 1
  • Yesterday I tried remaking files 5 or 6 times and all had the same issues. Today I deleted the file and made a new one (npx create-new-app .) npm start) and its working! Bizarre but i'll take it! – poeticider Apr 13 '22 at 10:28

1 Answers1

0

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

Seba99
  • 1,197
  • 14
  • 38