如何解决上游依赖冲突(react版本17因为依赖冲突而无法工作)

问题描述 投票:0回答:1

我安装了react版本18,但kakao-map-api没有安装在18版本中,所以我降级到react 17.2.0,但它不起作用。 我读了错误行,但我根本无法理解。我是否必须修复 package.json 文件中的所有脚本标记?

例如测试库版本、情感/反应版本?我如何知道适合react 17的版本?我强行尝试了命令“npm install” 在 cmd 中运行“react-kakao-maps-sdk”,当然,出于同样的原因它不起作用。 我尝试在命令行上降级 17 版本,也在 package.json 中尝试降级,但仍然不起作用。

通过命令行‘修复上游依赖冲突’,如何知道哪个版本、哪个库可以解决依赖问题?

如果我命令“npm install react-kakao-maps-sdk”,这是错误行。

npm install react-kakao-maps-sdk
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

npm ERR! code ERESOLVE

npm ERR! ERESOLVE could not resolve

npm ERR!

npm ERR! While resolving: @testing-library/[email protected]   

npm ERR! Found: [email protected] 

npm ERR! node_modules/react  

npm ERR!   peer react@">=16.8.0" from @emotion/[email protected]

npm ERR!   node_modules/@emotion/react

npm ERR!     peer @emotion/react@"^11.0.0-rc.0" from @emotion/[email protected]

npm ERR!     node_modules/@emotion/styled

npm ERR!       peerOptional @emotion/styled@"^11.3.0" from @mui/[email protected]

npm ERR!       node_modules/@mui/material

npm ERR!         peer @mui/material@"^5.0.0" from @mui/[email protected]

npm ERR!         node_modules/@mui/icons-material

npm ERR!         1 more (the 
root project)

npm ERR!       3 more (@mui/styled-engine, @mui/system, the root project)

npm ERR!     peerOptional @emotion/react@"^11.5.0" from @mui/[email protected]

npm ERR!     node_modules/@mui/material

npm ERR!       peer @mui/material@"^5.0.0" from @mui/[email protected]

npm ERR!       node_modules/@mui/icons-material

npm ERR!         @mui/icons-material@"^5.8.4" from the root project

npm ERR!       1 more (the root project)

npm ERR!     3 more (@mui/styled-engine, @mui/system, the 
root project)

npm ERR!   peer react@">=16.8.0" from @emotion/[email protected]

npm ERR!   node_modules/@emotion/styled

npm ERR!     peerOptional @emotion/styled@"^11.3.0" from @mui/[email protected]

npm ERR!     node_modules/@mui/material

npm ERR!       peer @mui/material@"^5.0.0" from @mui/[email protected]

npm ERR!       node_modules/@mui/icons-material

npm ERR!         @mui/icons-material@"^5.8.4" from the root project

npm ERR!       1 more (the root project)

npm ERR!     peerOptional @emotion/styled@"^11.3.0" from @mui/[email protected]      

npm ERR!     node_modules/@mui/styled-engine

npm ERR!       @mui/styled-engine@"^5.8.7" from @mui/[email protected]

npm ERR!       node_modules/@mui/system

npm ERR!         @mui/system@"^5.9.0" from @mui/[email protected]

npm ERR!         node_modules/@mui/material

npm ERR!     2 more (@mui/system, the root project)       

npm ERR!   12 more (@mui/base, @mui/icons-material, @mui/material, ...)

npm ERR!

npm ERR! Could not resolve dependency:

npm ERR! peer react@"^18.0.0" from @testing-library/[email protected]

npm ERR! node_modules/@testing-library/react

npm ERR!   @testing-library/react@"^13.3.0" from the root 
project
npm ERR!

npm ERR! Conflicting peer dependency: [email protected]        

npm ERR! node_modules/react  

npm ERR!   peer react@"^18.0.0" from @testing-library/[email protected]

npm ERR!   node_modules/@testing-library/react

npm ERR!     @testing-library/react@"^13.3.0" 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\USER\AppData\Local\npm-cache\eresolve-report.txt for a full report.

这是我的 package.json 文件。

{
  "name": "songpider-traveling-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.9.3",
    "@emotion/styled": "^11.9.3",
    "@mui/icons-material": "^5.8.4",
    "@mui/material": "^5.9.0",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "npm": "^8.15.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router": "^6.3.0",
    "react-scripts": "^2.1.3",
    "reactstrap": "^9.1.2",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

node.js reactjs npm dependencies
1个回答
-1
投票
npm install --legacy-peer-deps
© www.soinside.com 2019 - 2024. All rights reserved.