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

使用EAS CLI构建React Expo项目遇npm依赖冲突错误求助

解决Expo EAS构建时的依赖冲突问题

问题根源

你同时安装了两个抽屉导航依赖:旧版的react-navigation-drawer@2.7.2和新版的@react-navigation/drawer@6.6.6。旧版要求react-native-gesture-handler@^1.0.12,但你项目中使用的是2.12.1版本,导致npm依赖解析冲突。

解决方案

1. 移除旧版依赖(推荐)

旧版react-navigation-drawer已经被新版@react-navigation/drawer替代,完全没必要保留,直接卸载:

npm uninstall react-navigation-drawer

如果用Yarn:

yarn remove react-navigation-drawer

2. 更新代码中的导入引用

检查项目所有文件,把从react-navigation-drawer的导入替换为@react-navigation/drawer。比如:

  • 旧代码:
import { createDrawerNavigator } from 'react-navigation-drawer';
  • 新代码(适配React Navigation v6):
import { createDrawerNavigator } from '@react-navigation/drawer';

3. 重新安装依赖

npm install

4. 临时兼容方案(不推荐)

如果暂时无法移除旧版依赖,可以在EAS构建时强制使用旧版依赖解析规则,修改eas.json配置:

{
  "build": {
    "production": {
      "installCommand": "npm install --legacy-peer-deps"
    }
  }
}

注意:这种方式可能隐藏其他依赖问题,仅作为临时过渡方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 05:45:15