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

Expo项目安装@react-native-firebase/firestore依赖冲突求助

解决Expo项目中@react-native-firebase/firestore安装依赖冲突问题

问题核心原因

当前项目使用的@react-native-firebase/app版本为19.1.2,但安装@react-native-firebase/firestore@^19.2.1时,该模块要求对等依赖@react-native-firebase/app@19.2.2,导致版本匹配冲突。Windows与Mac的npm解析行为差异大概率源于npm版本或本地缓存差异。


解决方案

方案1:统一所有@react-native-firebase模块版本

firebase各模块要求严格版本一致,可选择升级所有模块至匹配版本,或安装与现有版本兼容的firestore:

  • 升级到同版本(推荐):
    先卸载现有firebase模块:
    npm uninstall @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/crashlytics
    
    重新安装统一版本的所有模块(含firestore):
    npm install --save @react-native-firebase/app@19.2.2 @react-native-firebase/auth@19.2.2 @react-native-firebase/crashlytics@19.2.2 @react-native-firebase/firestore@19.2.2 --legacy-peer-deps
    
  • 保持现有版本:
    安装与19.1.2兼容的firestore版本:
    npm install --save @react-native-firebase/firestore@19.1.2 --legacy-peer-deps
    

方案2:清理Mac本地npm缓存后重试

缓存异常可能导致依赖解析失败,执行以下步骤:

  1. 清理npm缓存:
    npm cache clean --force
    
  2. 删除本地依赖文件:
    rm -rf node_modules package-lock.json
    
  3. 重新安装所有依赖后再安装firestore:
    npm install --legacy-peer-deps
    npm install --save @react-native-firebase/firestore --legacy-peer-deps
    

方案3:强制跳过依赖检查(不推荐)

若以上方案无效,可使用--force强制安装,但可能引发运行时兼容性问题:

npm install --save @react-native-firebase/firestore --force

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 00:30:57