【问题标题】:Not able to install reactstrap无法安装 reactstrap
【发布时间】:2020-12-25 06:53:24
【问题描述】:

如果安装 react-icons、reactstrap 和 react-toastify

C:\Users\Anupam K Krishnan\Desktop\React20\four-tictactoe>npm install react-icons reactstrap  react-toastify
npm ERR!  code ERESOLVE
npm ERR!  ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR!  Found: react@17.0.1
npm ERR!  node_modules/react
npm ERR!  peer react@"*" from @testing-library/react@11.2.2
npm ERR!  node_modules/@testing-library/react
npm ERR!  @testing-library/react@"^11.2.2" from the root project
npm ERR!  peer react@"17.0.1" from react-dom@17.0.1
npm ERR!  node_modules/react-dom
npm ERR!  peer react-dom@"*" from @testing-library/react@11.2.2
npm ERR!  node_modules/@testing-library/react
npm ERR!  @testing-library/react@"^11.2.2" from the root project
npm ERR!  react-dom@"^17.0.1" from the root project
npm ERR!  2 more (reactstrap, react-transition-group)
npm ERR!  5 more (the root project, react-icons, react-toastify, ...)
npm ERR! 
npm ERR!  Could not resolve dependency:
npm ERR!  peer react@"0.14.x || ^15.0.0 || ^16.0.0" from react-popper@1.3.7
npm ERR!  node_modules/reactstrap/node_modules/react-popper
npm ERR!  react-popper@"^1.3.6" from reactstrap@8.8.0
npm ERR!  node_modules/reactstrap
npm ERR!  reactstrap@"*" 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\Anupam K Krishnan\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\Anupam K Krishnan\AppData\Local\npm-cache\_logs\2020-12-25T16_47_42_992Z-debug.log

如果使用--force

npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.1
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/react@11.2.2
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^11.2.2" from the root project       
npm WARN 6 more (react-dom, the root project, react-icons, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer react@"0.14.x || ^15.0.0 || ^16.0.0" from react-popper@1.3.7
npm WARN node_modules/reactstrap/node_modules/react-popper
npm WARN react-popper@"^1.3.6" from reactstrap@8.8.0
npm WARN node_modules/reactstrap
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: react@17.0.1
npm WARN node_modules/react
npm WARN peer react@"*" from @testing-library/react@11.2.2
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^11.2.2" from the root project       
npm WARN 6 more (react-dom, the root project, react-icons, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer react@"0.14.x || ^15.0.0 || ^16.0.0" from react-popper@1.3.7
npm WARN node_modules/reactstrap/node_modules/react-popper
npm WARN react-popper@"^1.3.6" from reactstrap@8.8.0
npm WARN node_modules/reactstrap
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! peer react@"*" from @testing-library/react@11.2.2
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@"^11.2.2" from the root project
npm ERR! peer react@"17.0.1" from react-dom@17.0.1
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"*" from @testing-library/react@11.2.2
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@"^11.2.2" from the root project
npm ERR! react-dom@"^17.0.1" from the root project
npm ERR! 2 more (reactstrap, react-transition-group)
npm ERR! 5 more (the root project, react-icons, react-toastify, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from create-react-context@0.3.0
npm ERR! node_modules/reactstrap/node_modules/create-react-context
npm ERR! create-react-context@"^0.3.0" from react-popper@1.3.7
npm ERR! node_modules/reactstrap/node_modules/react-popper
npm ERR! react-popper@"^1.3.6" from reactstrap@8.8.0
npm ERR! node_modules/reactstrap
npm ERR! reactstrap@"*" 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\Anupam K Krishnan\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\Anupam K Krishnan\AppData\Local\npm-cache\_logs\2020-12-25T17_16_41_640Z-debug.log

还尝试使用 SKIP_PREFLIGHT_CHECK=true 添加 .env 文件 即使这样也行不通



安装 reactstrap 时出现所有这些错误

我尝试了什么
1)删除节点模块和package-lock.json
2) 更新了 npm
3)重新安装npm

即使我尝试过 --force 但什么也没发生

还是有错误

【问题讨论】:

  • 贴出你的错误,而不是图片,安装reactstrap时的错误是什么,你能单独发一下吗
  • 您尝试此操作时遇到的错误是什么npm i -S reactstrap
  • @Anupam Kumar Krishnan 与其在评论中留下错误,不如编辑并粘贴您的问题。

标签: node.js reactjs npm


【解决方案1】:

要修复依赖关系树,请尝试按照以下步骤进行操作:

  1. 删除项目文件夹中的 package-lock.json(不是 package.json!)和/或 yarn.lock。
  2. 删除项目文件夹中的 node_modules。
  3. 从项目文件夹的 package.json 文件中的依赖项和/或 devDependencies 中删除“babel-eslint”。
  4. 运行 npm install 或 yarn,具体取决于您使用的包管理器。

在大多数情况下,这应该足以解决问题。 如果这没有帮助,您可以尝试其他一些方法:

  1. 如果您使用 npm,请安装 yarn (http://yarnpkg.com/) 并使用它重复上述步骤。 这可能会有所帮助,因为 npm 已经知道包提升的问题,这些问题可能会在未来的版本中得到解决。

  2. 检查 C:\Users\asus\Desktop\react20\node_modules\babel-eslint 是否在您的项目目录之外。 例如,您可能不小心在主文件夹中安装了一些东西。

  3. 尝试在您的项目文件夹中运行 npm ls babel-eslint。 这将告诉您安装了 babel-eslint 的其他包(除了预期的 react-scripts)。

如果没有其他帮助,请将 SKIP_PREFLIGHT_CHECK=true 添加到项目中的 .env 文件中。 如果您仍然想继续,这将永久禁用此预检检查。

附:我们知道这条消息很长,但请阅读上面的步骤 :-) 我们希望它们对您有所帮助!

如果没有任何效果,则运行命令:

npm install reactstrap --legacy-peer-deps

为了解决这个问题,运行上面的命令来解决这个问题

【讨论】:

    猜你喜欢
    • 2020-06-25
    • 1970-01-01
    • 2021-04-03
    • 2018-07-26
    • 2018-06-23
    • 2021-07-26
    • 2020-10-12
    • 2023-01-30
    • 2014-01-08
    相关资源
    最近更新 更多