【问题标题】:how do i fix the upstream dependency error? i have tried doing npm install --legacy-peer-deps and npm install --force but that causes problems further如何修复上游依赖错误?我试过做 npm install --legacy-peer-deps 和 npm install --force 但这会导致进一步的问题
【发布时间】:2021-07-18 12:28:37
【问题描述】:

这是我遇到的错误(有人可以向我解释为什么会发生此类错误,以及是否有办法将 npm 更新为我拥有的 react 版本。):

PS C:\Naman Kothari\udemy course\react\thelastone> npm i react-tilt
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: thelastone@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.0.0 || ^16.0.0-beta || ^16.0.0" from react-tilt@0.1.4
npm ERR! node_modules/react-tilt
npm ERR!   react-tilt@"*" 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\namrata kothari\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\namrata kothari\AppData\Local\npm-cache\_logs\2021-04-24T15_15_44_230Z-debug.log

这是我的 package.json(它主要包含我安装 create-react-app npm 时默认创建的所有包)。

{
  "name": "thelastone",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.12.0",
    "@testing-library/react": "^11.2.6",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "tachyons": "^4.12.0",
    "web-vitals": "^1.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

【问题讨论】:

  • 我在 Angular 中遇到了相同类型的问题。你能修复它吗?如果是,请分享。
  • @anand 这只是因为 react-tilt 不适用于最新版本的 REACT。只需将 react 和 react-dom 的版本更改为 16.14.0 并在终端中编写 npm install 即可解决问题。

标签: reactjs npm npm-install


【解决方案1】:

我遇到的问题是 react-tilt 不适用于 react 17 版。

我尝试使用“react-tilty”包解决了我的问题:

npm i react-tilty

【讨论】:

    猜你喜欢
    • 2021-11-28
    • 2021-05-07
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 2022-01-08
    • 2021-05-20
    • 2015-02-25
    相关资源
    最近更新 更多