You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装react-native-maps出现npm ERESOLVE依赖解析错误是什么意思?

react-native-maps安装ERESOLVE报错解答

报错原文

终端
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: instalawnrn@0.0.1
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"17.0.1" from the root project
npm ERR! peer react@">= 16.0 || < 17.0" from react-native-maps@0.28.0
npm ERR! node_modules/react-native-maps
npm ERR! react-native-maps@"" from the root project
npm ERR! 2 more (react-native, react-native-web)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-dom@17.0.2
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@">=16.5.1" from react-native-web@0.11.7
npm ERR! node_modules/react-native-web
npm ERR! peer react-native-web@"^0.11" from react-native-maps@0.28.0
npm ERR! node_modules/react-native-maps
npm ERR! react-native-maps@"
" 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\kcopu\AppData\Local\npm-cache\eresolve-report.txt for a full report.

错误含义

这是npm 7及以上版本自带的严格对等依赖校验机制触发的报错,核心原因是你项目现有依赖版本和react-native-maps要求的依赖版本范围不匹配,具体冲突点有两个:

  • 你项目本地已安装react@17.0.1,但待安装的react-native-maps@0.28.0要求的react版本范围是>=16.0 || <17.0,天生不兼容17.x版本的react
  • react-native-maps@0.28.0依赖的react-native-web@0.11.7,同时要求react@17.0.2和对应版本的react-dom,和你本地的react@17.0.1也存在版本冲突

解决方案

  • 方案1(优先推荐):安装支持react 17+的高版本react-native-maps,执行命令:npm install react-native-maps@latest,新版组件已经修复了版本适配问题,不会出现兼容风险
  • 方案2(稳定适配):降级项目的react版本到符合react-native-maps@0.28.0要求的范围,比如安装react@16.14.0,所有依赖都匹配不会有兼容问题
  • 方案3(临时应急):安装时跳过对等依赖校验,执行命令:npm install react-native-maps --legacy-peer-deps,这个方案只是强制跳过校验,后续运行可能出现未知兼容问题,不建议长期使用

内容的提问来源于stack exchange,提问作者Papa Kodi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 04:30:03