close

[Solved] npm ERR! @testing-library/react@”^12.0.0″ from the root project

I am trying to make a new project with npx create-react-app nfc_app but I am facing the following error npm ERR! @testing-library/react@”^12.0.0″ from the root project in ReactJS. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.

How npm ERR! @testing-library/react@”^12.0.0″ from the root project Error Occurs?

I am trying to make a new project with npx create-react-app nfc_app but I am facing the following error my project was also created with an error.

Installing template dependencies using npm…
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-18@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
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@”^12.0.0″ from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with –force, or –legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve npm ERR! @testing-library/react@”^12.0.0″ from the root project Error?

  1. How To Solve npm ERR! @testing-library/react@”^12.0.0″ from the root project Error?

    To Solve npm ERR! @testing-library/react@”^12.0.0″ from the root project Error Alternativly You can Downgrade React to its Earlier version. en Delete package-lock.json file. Now, Open Your package.json file and change react react-dom to an earlier version "react": "^17.0.2" & "react-dom": "^17.0.2" Now, you can run npm install. and Now, your error must be solved.

  2. npm ERR! @testing-library/react@”^12.0.0″ from the root project

    To Solve npm ERR! @testing-library/react@”^12.0.0″ from the root project Error In My case, I have run npx create-react-app nfc_app command and this command give me the above error But when I ran my project there is a web-vitals missing error occurred. If an Error occurs even if your project is created and missing any single dependency then Follow this step. First of all, Open Your project and Delete node_modules folder. Then Delete package-lock.json file. Now, Just install whichever package is missing. In my case it was web-vitals was missing so I just ran npm i web-vitals –save-dev. and then ran npm install Now, Your error must be solved and you can run npm run build and npm start again.

Solution 1: Install package with –force command

You just need to install package force with –force command. Just put –force at the end of your command. For Example.

npm install @mui/material @emotion/react @emotion/styled --force

Whenever You are trying to install any packages Just add –force Or –legacy-peer-deps at the end of your command. Now, Your error must be solved. Thank You.

Solution 2: Install the package with –legacy-peer-deps command

You just need to install the package with –legacy-peer-deps command. Just put –legacy-peer-deps at the end of your command. For Example.

npm install @mui/material @emotion/react @emotion/styled --legacy-peer-deps

Whenever You are trying to install any packages Just add –force Or –legacy-peer-deps at the end of your command. Now, Your issue must be solved. Thank You.

Solution 3: Install Missing Dependancy

In My case, I have run npx create-react-app nfc_app command and this command give me the above error But when I ran my project there is a web-vitals missing error occurred. If an Error occurs even if your project is created and missing any single dependency then Follow this step.

  1. First of all, Open Your project and Delete node_modules folder.
  2. Then Delete package-lock.json file.
  3. Now, Just install whichever package is missing.
  4. In my case it was web-vitals was missing so I just ran npm i web-vitals –save-dev.
  5. and then ran npm install
  6. Now, Your error must be solved and you can run npm run build and npm start again.

Solution 4: Downgrade React

Alternativly You can Downgrade React to its Earlier version.

  1. First of all Just Delete node_modules folder.
  2. Then Delete package-lock.json file.
  3. Now, Open Your package.json file and change react react-dom to an earlier version
  4. "react": "^17.0.2" & "react-dom": "^17.0.2"
  5. Now, you can run npm install.
  6. and Now, your error must be solved.

Summary

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Leave a Comment