React-bootstrap-table-next 依赖树问题

tri*_*g79 9 npm reactjs react-bootstrap-table

我在安装时收到错误npm install react-bootstrap-table-next --save

我不明白它告诉我什么,也不明白如何解决,任何指导表示赞赏:

错误:

$ npm install react-bootstrap-table-next --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: frontend@0.1.0
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@"*" 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.
Run Code Online (Sandbox Code Playgroud)

我的依赖项:

  "dependencies": {
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.3",
    "@testing-library/user-event": "^12.6.0",
    "axios": "^0.21.1",
    "bootstrap": "^4.6.0",
    "react": "^17.0.1",
    "react-bootstrap": "^1.4.3",
    "react-dom": "^17.0.1",
    "react-paypal-button-v2": "^2.6.2",
    "react-redux": "^7.2.2",
    "react-router-bootstrap": "^0.25.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.1",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "web-vitals": "^0.2.4"
  },

Run Code Online (Sandbox Code Playgroud)

tri*_*g79 14

经过进一步挖掘,该问题似乎与 NPM v7 有关,运行以下命令解决了该问题:

npm install react-bootstrap-table-next --save --legacy-peer-deps

关键信息如下所示,摘自以下帖子:

无法解析依赖树-reactjs

graphql-erresolve-无法解决依赖关系

NPM v7

NPM v7 最近发布,这是当前(截至 2020 年 11 月)节点:当前映像使用的版本。

NPM7 带来的最大变化可能与对等依赖项有关 - 如果可能的话,NPM 现在应该能够自动安装它们。在这里阅读更多内容。

正如文档中所述,在无法解决冲突的情况下,NPM 现在应该抛出错误而不是警告,这就是您所看到的。

另一方面,我使用您的设置和 NPM v7.0.8 只收到警告,没有错误,我不知道为什么。然而,所报告的问题本质上是相同的,因此解决方案应该非常相似。