npm 错误!代码 ERESOLVE npm 错误!ERESOLVE 无法解析反应中的依赖关系树

Sha*_*een 18 npm

我正在做一个 meern 项目,我使用了以下命令

npm 我反应路由器 dom axios 反应贝宝快速结账

我遇到了以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: client@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@"~0.14.8 || ^15.5.0" from react-paypal-express-checkout@1.0.5
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
Run Code Online (Sandbox Code Playgroud)

我的 package.json 文件是:

{
  "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"
  }
}
Run Code Online (Sandbox Code Playgroud)

谁能帮我清除这个错误。

提前致谢

小智 54

我遇到了类似的问题,但错误发生在npx create-react-app.

我找到了解决办法;你需要输入npm config set legacy-peer-deps true.