当我 npm 安装 react-leaflet-draw react-leaflet --save 时出现问题

problem when i npm install react-leaflet-draw react-leaflet --save

我在尝试安装 react-leaflet-draw react-leaflet 时遇到问题 -- 保存我有这个错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: siis-new@0.1.0
npm ERR! Found: react-leaflet@3.2.5
npm ERR! node_modules/react-leaflet
npm ERR!   react-leaflet@"^3.2.5" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-leaflet@"^2.0.0" from react-leaflet-draw@0.19.8
npm ERR! node_modules/react-leaflet-draw
npm ERR!   react-leaflet-draw@"*" 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 /Users/hafizewp/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/PC/.npm/_logs/2022-04-12T10_02_53_677Z-debug.log

而且我不想更改我的 React 版本!

我们遇到了类似的问题,这是由于版本冲突!

尝试了 --legacy-peer-deps 选项,除了反应库之外,我们还需要添加 leafelet 和 leaflet-draw JS 库。这是我们当前依赖项的样子,我们使用的是节点 v16.14.2

希望这对您的情况有所帮助

"dependencies": {
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@id-sdk/util": "^3.0.0-pre.10",
"@material-ui/icons": "^4.11.3",
"@mui/icons-material": "^5.6.1",
"@mui/lab": "^5.0.0-alpha.77",
"@mui/material": "^5.6.1",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"leaflet": "^1.7.1",
"leaflet-draw": "^1.0.4",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-dotenv": "^0.1.3",
"react-leaflet": "3.2.1",
"react-leaflet-draw": "0.19.8",
"react-query": "^3.34.19",
"react-scripts": "5.0.0",
"uninstall": "^0.0.0",
"web-vitals": "^2.1.4"
}