【问题标题】:npm install unable to resolve dependency treenpm install 无法解析依赖树
【发布时间】:2021-05-12 01:17:42
【问题描述】:

所以我从 Creative Tim 的网站购买了高级仪表板主题,现在当我尝试使用它时,我无法安装这些软件包。当我运行npm install 时,出现以下错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: argon-dashboard-pro-react@1.2.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0" from react-bootstrap-table-next@4.0.3
npm ERR! node_modules/react-bootstrap-table-next
npm ERR!   react-bootstrap-table-next@"4.0.3" 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\acer\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\acer\AppData\Local\npm-cache\_logs\2021-02-08T12_06_48_302Z-debug.log

如何解决此错误。我也试过 --legacy-peer-deps 和 --force 。似乎没有任何效果。

【问题讨论】:

标签: javascript node.js reactjs npm


【解决方案1】:

试试这个命令

npm cache clean --force

npm install --legacy-peer-deps

【讨论】:

    【解决方案2】:

    我遇到了这个问题,两种解决方案中的任何一种都对我有用。它们是:

    1. npm install --legacy-peer-deps

      如果您好奇它的作用是什么? 软件包将使用 --legacy 标志安装。该命令忽略所有 安装时的对等依赖项,以 npm 版本 4 的样式通过 第 6 版。

    2. 此错误来自 npm 7.x 版。因此,另一个解决方案是 降级到 npm 6.x。

    参考:Refer this for more info

    【讨论】:

      【解决方案3】:

      我遇到了类似的错误,添加 --legacy-peer-deps 为我解决了这个问题。 npm install --legacy-peer-deps.

      阅读更多关于“--legacy-peer-deps”here的信息。

      【讨论】:

      • 这是 hack 修复还是有解决问题的方法?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 2021-06-16
      • 2022-01-08
      • 2021-08-04
      相关资源
      最近更新 更多