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

升级Expo SDK至48后因AsyncStorage与Firebase Auth问题无法启动项目

问题:Expo SDK从v45升级到v48后因AsyncStorage依赖问题无法启动

错误现象

将Expo SDK从v45升级到v48后,项目无法启动,直接触发错误(其他用户多为警告),错误信息如下:

Android Bundling complete 118ms ERROR  Invariant Violation: AsyncStorage has been removed from react-native core. It can now be installed and imported from '@react-native-async-storage/async-storage' instead of 'react-native'

排查过程

  • 自身代码已正确从@react-native-async-storage/async-storage导入AsyncStorage
  • 确认问题根源是firebase-auth依赖内部使用了react-native核心包中的AsyncStorage
  • 尝试网上推荐的手动配置auth持久化方案:
    const auth = initializeAuth(app, { persistence: getReactNativePersistence(AsyncStorage)});
    
    但无法从firebase/auth/react-native导入getReactNativePersistence和initializeAuth

当前package.json配置

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "debug": "firebase emulators:start --inspect-functions"
  },
  "dependencies": {
    "@expo/config-plugins": "~6.0.0",
    "@react-native-async-storage/async-storage": "1.17.11",
    "@react-native-camera-roll/camera-roll": "^5.2.4",
    "@react-native-community/datetimepicker": "6.7.3",
    "@react-native-community/netinfo": "9.3.7",
    "@react-native-community/slider": "4.4.2",
    "@react-native-firebase/app": "^17.3.1",
    "@react-native-firebase/auth": "^17.3.1",
    "@react-navigation/bottom-tabs": "^6.3.2",
    "@react-navigation/elements": "^1.3.3",
    "@react-navigation/material-top-tabs": "^6.2.2",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/stack": "^6.2.2",
    "@react-navigation/web": "^1.0.0-alpha.9",
    "axios": "^0.21.1",
    "expo": "^48.0.4",
    "expo-av": "~13.2.1",
    "expo-blur": "~12.2.2",
    "expo-camera": "~13.2.1",
    "expo-device": "~5.2.1",
    "expo-env-info": "^1.0.5",
    "expo-file-system": "~15.2.2",
    "expo-image-manipulator": "~11.1.1",
    "expo-image-picker": "~14.1.1",
    "expo-image-picker-multiple": "^1.4.1",
    "expo-linking": "~4.0.1",
    "expo-location": "~15.1.1",
    "expo-media-library": "~15.2.2",
    "expo-modules-autolinking": "~1.1.0",
    "expo-notifications": "~0.18.1",
    "expo-permissions": "~14.1.1",
    "expo-server-sdk": "^3.6.0",
    "expo-status-bar": "~1.4.4",
    "expo-video-player": "^1.6.1",
    "expo-video-thumbnails": "~7.2.1",
    "firebase": "^8.2.3",
    "firebase-admin": "^10.3.0",
    "firebase-functions": "^3.21.2",
    "formik": "^2.2.9",
    "moment": "^2.29.1",
    "react": "^18.2.0",
    "react-dom": "18.2.0",
    "react-infinite-scroll-component": "^6.1.0",
    "react-native": "0.71.3",
    "react-native-bottomsheet-reanimated": "0.0.39",
    "react-native-dropdown-picker": "^4.0.9",
    "react-native-expo-cached-image": "^1.3.1",
    "react-native-form-validator": "^0.3.5",
    "react-native-geocoding": "^0.5.0",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-google-places-autocomplete": "^2.1.2",
    "react-native-image-modal": "^2.0.3",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-interactable-reanimated": "0.0.15",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-map-clustering": "^3.4.2",
    "react-native-maps": "1.3.2",
    "react-native-material-menu": "^2.0.0",
    "react-native-mentions": "^1.1.4",
    "react-native-modalbox": "^2.0.2",
    "react-native-optimized-flatlist": "^1.0.4",
    "react-native-orientation": "^3.1.3",
    "react-native-pager-view": "6.1.2",
    "react-native-paper": "^4.9.2",
    "react-native-parsed-text": "0.0.22",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-progress": "^5.0.0",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "~2.14.4",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-svg": "13.4.0",
    "react-native-tab-view": "^3.1.1",
    "react-native-unimodules": "~0.14.5",
    "react-native-vector-icons": "^8.1.0",
    "react-native-video": "^2.3.1",
    "react-native-video-player": "^0.12.0",
    "react-native-walkthrough-tooltip": "^1.3.1",
    "react-native-web": "~0.18.11",
    "react-navigation": "^4.4.4",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.9",
    "redux-thunk": "^2.4.2",
    "rn-tooltip": "^3.0.1",
    "rne-modal-tooltip": "gist:b28c003d87c619674def0878473338a0",
    "unimodules-permissions-interface": "^6.1.0",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "eslint": "^8.17.0",
    "eslint-plugin-react": "^7.30.0"
  },
  "private": true
}

核心疑问

为何该问题在本地环境中触发的是错误而非警告,直接导致项目无法启动?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 09:45:09