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

执行npm install react-native-image-picker时遇ERESOLVE依赖冲突错误

解决npm安装react-native-image-picker时的ERESOLVE依赖冲突问题

问题重现

执行命令 npm install react-native-image-picker 时触发以下依赖解析错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-navigation-tabs@2.11.2
npm ERR! Found: react-native-gesture-handler@2.9.0
npm ERR! node_modules/react-native-gesture-handler
npm ERR! peer react-native-gesture-handler@"*" from react-native-tab-view@2.16.0
npm ERR! node_modules/react-native-tab-view
npm ERR! react-native-tab-view@"^2.15.2" from react-navigation-tabs@2.11.2
npm ERR! node_modules/react-navigation-tabs
npm ERR! react-navigation-tabs@"^2.11.2" from the root project
npm ERR! peer react-native-gesture-handler@">= 1.5.0" from react-navigation-stack@2.10.4
npm ERR! node_modules/react-navigation-stack
npm ERR! react-navigation-stack@"^2.10.4" from the root project
npm ERR! 1 more (the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-gesture-handler@"^1.0.0" from react-navigation-tabs@2.11.2
npm ERR! node_modules/react-navigation-tabs
npm ERR! react-navigation-tabs@"^2.11.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react-native-gesture-handler@1.10.3
npm ERR! node_modules/react-native-gesture-handler
npm ERR! peer react-native-gesture-handler@"^1.0.0" from react-navigation-tabs@2.11.2
npm ERR! node_modules/react-navigation-tabs
npm ERR! react-navigation-tabs@"^2.11.2" from the root project

解决方案

1. 临时忽略peer依赖冲突(最快解决)

npm v7及以上默认启用严格的peer依赖检查,旧版本的react-navigation-tabs未更新peer依赖声明,可通过以下命令绕过:

npm install react-native-image-picker --legacy-peer-deps

或者强制安装(风险略高,但多数场景可用):

npm install react-native-image-picker --force

2. 降级react-native-gesture-handler到兼容版本

直接安装react-navigation-tabs要求的^1.0.0版本范围内的最新版:

npm install react-native-gesture-handler@1.10.3

安装完成后再执行npm install react-native-image-picker即可正常安装。

3. 升级导航库到最新版本(长期方案)

react-navigation-tabs@2.11.2是较旧的版本,当前react-navigation已迭代到6.x,升级可彻底解决依赖冲突,但需适配新版API:

  1. 卸载旧导航包:
npm uninstall react-navigation-tabs react-navigation-stack react-native-tab-view
  1. 安装新版基础依赖:
npm install @react-navigation/native
npm install react-native-screens react-native-safe-area-context
  1. 安装底部导航组件(替代原tabs):
npm install @react-navigation/bottom-tabs

之后按新版react-navigation文档调整项目中的导航代码即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 02:17:23