关于 Reactstrap 安装

Regarding Reactstrap installation

当我尝试使用此命令安装反应带但无法安装反应带时。

npm install reactstrap --save

那次我收到这个错误

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   4 more (react-dom, react-popper, the root project, reactstrap)
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!     1 more (reactstrap)
npm ERR!   3 more (react-popper, the root project, reactstrap)
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\prajjkum\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\prajjkum\AppData\Local\npm-cache\_logs20-12-26T11_13_07_327Z-debug.log

那么如何解决这个错误,请帮助我...我已经尝试卸载然后重新安装,但它不再工作了,所以我把它贴在这里

这里的问题似乎肯定与 npm 7 有关。 不幸的是,我没有收到您的设置错误,只有警告,我不知道为什么。

如果问题确实出在 npm 上,我可以提出两点建议:

  1. npm install --save reactstrap --legacy-peer-deps
  2. npx -p npm@6 npm install.

在继续任何步骤之前,确保删除 node_modules 和 package-lock.json