"@popperjs/core": "^2.6.0",
"@testing-/jest-dom": "^5.11.9",
"@testing-/react": "^11.2.3",
"@testing-/user-event": "^12.6.2",
"bootstrap": "^4.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"react-transition-group": "^4.4.1",
我在包中的依赖版本。json文件。
G: 项目 confusion>反应;NPM install——save reactstrap
npm WARN erresolve覆盖对等依赖
npm WARN发现:react@17.0.1
npm WARN node_modules/react
npm WARN peer react@">"@testing-/react@11.2.3
npm WARN node_modules/@testing-/react
npm WARN @testing-/react@"^11.2.3">
npm WARN无法解析依赖项:
npm WARN peer react@"0.14。X || ^15.0.0 || ^16.0.0"from react-popper@1.3.7
npm WARN node_modules/react-popper
npm WARN react-popper@"^1.3.6"从reactstrap@8.9.0
npm警告node_modules/reactstrap
npm ERR!code erresolve
npm ERR!无法解析依赖树
npm犯错!发现:react@17.0.1
npm ERR!node_modules/react
同行react@"";from @testing-/react@11.2.3
npm ERRnode_modules/@testing-/react
@testing——/react@" ^ 11.2.3"从根项目
npm ERR!同行react@" 17.0.1"from react-dom@17.0.1
npm ERR!node_modules/react-dom
npm ERR!同行react-dom@"";from @testing-/react@11.2.3
npm ERRnode_modules/@testing-/react
@testing——/react@" ^ 11.2.3"从根项目
npm ERR!react-dom@" ^ 17.0.1"从根项目
npm ERR!
npm ERR!
npm ERR!
npm ERR!无法解析依赖项:
npm ERR!同行react@" ^ 0.14.0 | | ^ 15.0.0 | | ^ 16.0.0"from create-react-context@0.3.0
npm ERR!node_modules/node_modules/create-react-context
npm ERR!create-react-context@" ^ 0.3.0"from react-popper@1.3.7
npm ERR!node_modules/react-popper
node_modules/reactstrap
reactstrap@"";从根项目
npm ERR!npm犯错!修复上游依赖冲突,或者重试
npm ERR!使用——force或——legacy-peer-deps
npm ERR!接受不正确的(并且可能损坏的)依赖项解析。
这是因为npm version 7中的一个变化。请参阅此处的突破性更改部分。您可以通过使用底部错误告诉您使用的标志来修复它:npm i reactstrap --legacy-peer-deps
。如果您的其他依赖项之一已经将reactstrap作为对等依赖项,那么由于v7中的更改,您可能根本不需要安装它(您可以使用npm ls reactstrap
检查)。
尝试在您的package.json
"engines": {
"npm": ">=8.7.0"
},
"overrides": {
"react": "$react"
}
这将强制react成为"dependencies"
中定义的所有依赖项的版本(&一层又一层)。你需要"最近的";因为它在某些版本中有bug(我的版本是8.3.0,覆盖不起作用)。
看到https://docs.npmjs.com/cli/v8/configuring-npm/package-json覆盖
有两种方法
方法1:
可以指定--legacy-peer-deps
安装新包时的标志。
# For NPM
npm install package_name --legacy-peer-deps
#For Yarn
yarn add package_name --legacy-peer-deps
方法2:如果你不想指定--legacy-peer-deps
每次为项目安装新包时标记。
您可以简单地在项目的根目录下创建一个文件。文件名为.npmrc
(用于NPM)或.yarnrc
(For Yarn)。用以下命令更新文件:
For.npmrc
:
legacy-peer-deps=true
For.yarnrc
:
npmClientArgs: "--legacy-peer-deps"
希望对你有所帮助:)
删除节点模块,然后npm i reactstrap --legacy-peer-deps
然后npm install --force
帮我解决了
要强制安装任何依赖,请运行以下命令:NPM I——力此命令强制安装软件包而不会出现任何错误。
解决REACT_SPRING安装问题尝试
npm install --force
然后
npm audit fix --force