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

添加NavigationContainer后Android打包失败:无法解析expo-auth-session

React Native Expo项目Android打包失败解决方案

问题概述

添加NavigationContainer后出现打包失败,错误提示:

Android Bundling failed 3758ms C:\My Work\React Native\First\node_modules\expo\AppEntry.js (876 modules) Unable to resolve "expo-auth-session" from "node_modules@clerk\clerk-expo\dist\useOAuth.js"

问题原因

项目中使用@clerk/clerk-expo的useOAuth钩子实现Google登录,但该功能依赖expo-auth-session包,而你的package.json中未安装此依赖。升级CLI或调整React版本无法解决该问题,因为核心是缺少必要依赖。

解决方案

  1. 安装缺失依赖
    在项目根目录执行命令:

    npx expo install expo-auth-session
    
  2. 清除缓存并重启项目
    清除Expo缓存,避免缓存导致的依赖未加载问题:

    npx expo start --clear
    
  3. 重新打包Android项目
    执行打包命令:

    npm run android
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 16:27:16