react- 依赖版本冲突
### react- 依赖版本冲突
```json
ELIFECYCLE Command failed with exit code 1.
qiuliwei@192 react-ant-admin-main % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@5.0.1
npm ERR! Found: typescript@5.3.2
npm ERR! node_modules/typescript
npm ERR! typescript@"^5.3.2" from the root project
npm ERR! peerOptional typescript@"5" from @formatjs/intl@2.9.9
npm ERR! node_modules/@formatjs/intl
npm ERR! @formatjs/intl@"2.9.9" from react-intl@6.5.5
npm ERR! node_modules/react-intl
npm ERR! react-intl@"^6.5.5" from the root project
npm ERR! 3 more (fork-ts-checker-webpack-plugin, react-intl, tsutils)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" 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!
```
让我们检查[email protected]包的对等依赖关系:
```json
$ npm view [email protected] peerDependencies
{ react: '>= 16', typescript: '^3.2.1 || ^4' }
```
```json
有两种解决方案:
将typescript程序包降级到兼容的版本。
npm i typescript@^4 -S
使用package.json的重写配置
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.68",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^5.3.3",
"web-vitals": "^2.1.4"
},
"overrides": {
"react-scripts": {
"typescript": "^5"
}
},
```
本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:admin@ptpc120.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。
Please Sign in After a review