'npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree in react

I am doing a mern project in that I used the following command

npm i react-router-dom axios react-paypal-express-checkout

In that I faced the following error

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@"~0.14.8 || ^15.5.0" from [email protected]
npm ERR! node_modules/react-paypal-express-checkout
npm ERR!   react-paypal-express-checkout@"*" 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.
npm ERR!
npm ERR! See C:\Users\nahee\AppData\Local\npm-cache\eresolve-report.txt for a full report.    

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nahee\AppData\Local\npm-cache\_logs\2022-04-11T15_43_33_096Z-debug.log

And my package.json file is:

{
  "name": "animal_feedmart",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^5.0.0",
    "cloudinary": "^1.23.0",
    "concurrently": "^5.3.0",
    "cookie-parser": "^1.4.5",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "express-fileupload": "^1.2.0",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^5.10.1"
  },
  "devDependencies": {
    "nodemon": "^2.0.4"
  }
}

Can anyone help me to clear this error.

Thanks in advance

npm


Solution 1:[1]

I had a similar issue but the errors were after npx create-react-app. I found a solution, you need to type npm config set legacy-peer-deps true. But I don't know if this command will help you

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 ???? ??????