Expo应用卡在闪屏界面无报错,求技术排查方案
问题:Expo托管应用构建后卡在闪屏界面
之前运行正常的Expo托管应用,现在构建后卡在闪屏界面。尝试过以下操作均无效:
- 回退到确认可用的旧版本项目
- 删除并重装
node_modules(新旧版本都试过) - 朋友克隆仓库后也出现相同问题,排除环境因素
- 重置Apple Silicon MacBook Pro,重装homebrew、watchman、node、yarn、xcode和expo-cli
- 执行
expo upgrade和expo doctor修复
目前收到watchman警告,构建日志如下:
chaserobbins@Chases-MacBook-Pro Handle-Customer-App % expo start -c Starting project at /Users/chaserobbins/Documents/GitHub/Handle-Customer-App Starting Metro Bundler Your JavaScript transform cache is empty, rebuilding (this may take a minute). ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █ ▄▄▄▄▄ █▄▀▀▄▄ ▀█ █ ▄▄▄▄▄ █ █ █ █ ███▄█ ▀▄▄█ █ █ █ █ █▄▄▄█ ██▄▀▄▀▀▀█▀█ █▄▄▄█ █ █▄▄▄▄▄▄▄█ █ ▀▄▀▄▀ █▄▄▄▄▄▄▄█ █▄ ▀ ▀▄█▀ ▄▄▀▀█▀ █▄█▀█▀▀▄█ █▄▀▄▄█▀▄▄▀▀ ▀▄▄▄▀▀███▄▀▀ █ █▀▄▄█ ▄▄ ▀ █▄▄▀▄ █ ▄▀▀█▀ ██ █ ▄▀▄▀▀▄█▄██ ▄▄█ ▄▀ ██▄▀ █ █▄█▄▄▄▄▄█ ▀▀ █ ▄▄▄ ▄▀▄█ █ ▄▄▄▄▄ ██▀ ▄ ▄█ █▄█ ██▀ █ █ █ █ █ █▀▀▀██▄ ▄ ▄ █▀▀█ █ █▄▄▄█ █▀▀ █▄ ▄█▀▀▄█ █ █▄▄▄▄▄▄▄█▄██▄██▄▄▄▄█▄▄███▄█ › Metro waiting on exp://192.168.0.107:19000 › Scan the QR code above with Expo Go (Android) or the Camera app (iOS) › Press a │ open Android › Press i │ open iOS simulator › Press w │ open web › Press r │ reload app › Press m │ toggle menu › Press ? │ show all commands Logs for your project will appear below. Press Ctrl+C to exit. watchman warning: Recrawled this watch 27 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run: `watchman watch-del '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App' ; watchman watch-project '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App'` Recrawled this watch 27 times, most recently because: MustScanSubDirs UserDroppedTo resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run: `watchman watch-del '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App' ; watchman watch-project '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App'` › Opening on iOS... › Opening exp://192.168.0.107:19000 on iPhone 12 › Press ? │ show all commands iOS Bundling complete 38112ms
项目的package.json内容:
{ "scripts": { "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios", "web": "expo start --web", "eject": "expo eject" }, "dependencies": { "@babel/preset-typescript": "^7.18.6", "@expo/config-plugins": "5.0.0", "@expo/vector-icons": "^12.0.0", "@gorhom/bottom-sheet": "^4.1.3", "@react-native-community/hooks": "^2.6.0", "@react-navigation/bottom-tabs": "^6.0.5", "@react-navigation/native": "^6.0.2", "@react-navigation/native-stack": "^6.1.0", "@react-navigation/stack": "^6.0.7", "@stripe/stripe-react-native": "0.2.3", "algoliasearch": "^4.10.5", "expo": "44.0.0", "expo-constants": "13.0.1", "expo-file-system": "13.1.4", "expo-firebase-recaptcha": "2.1.0", "expo-font": "10.0.4", "expo-haptics": "~11.1.0", "expo-image-picker": "12.0.1", "expo-linear-gradient": "11.0.3", "expo-linking": "3.0.0", "expo-notifications": "0.14.0", "expo-status-bar": "1.2.0", "expo-store-review": "5.1.0", "expo-updates": "0.11.7", "firebase": "8.2.3", "moti": "^0.18.0", "node-geometry-library": "^1.2.5", "react": "^18.2.0", "react-dom": "^18.2.0", "react-instantsearch-native": "^6.12.1", "react-native": "0.64.3", "react-native-confetti-cannon": "^1.5.2", "react-native-confirmation-code-field": "^7.3.0", "react-native-gesture-handler": "2.1.0", "react-native-maps": "0.29.4", "react-native-reanimated": "2.3.1", "react-native-safe-area-context": "3.3.2", "react-native-screens": "3.10.1", "react-native-svg": "12.1.1", "react-native-web": "~0.13.12", "react-native-webview": "11.15.0", "shorthash": "^0.0.2" }, "devDependencies": { "@babel/core": "~7.9.0", "eslint": "^8.11.0", "eslint-plugin-react": "^7.29.4" }, "private": true, "name": "Handle-Customer-App", "version": "1.0.0", "resolutions": { "react-native": "0.63.4" } }
排查思路与解决建议
1. 处理watchman警告
先执行日志中提示的命令清除watchman缓存:
watchman watch-del '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App' ; watchman watch-project '/Users/chaserobbins/Documents/GitHub/Handle-Customer-App'
之后重启Metro服务,观察是否还出现重复爬取警告。
2. 修复依赖版本冲突
从package.json中能看到明显的版本不兼容问题:
- Expo 44对应的React版本应为17.0.1,当前安装的React 18.2.0版本过高,存在兼容性问题
resolutions字段强制指定react-native为0.63.4,但dependencies中写的是0.64.3,Expo 44对应的react-native版本是0.64.3,该配置会导致版本不一致@babel/preset-typescript7.18.6与@babel/core7.9.0版本不匹配,高版本preset需要对应版本的babel核心
建议:
- 删除
resolutions字段,保持Expo对应的react-native版本一致 - 将React版本降级到17.0.1,匹配Expo 44的要求
- 更新
@babel/core到与@babel/preset-typescript兼容的版本(如7.18.6)
3. 查看闪屏后的详细错误日志
构建完成后卡在闪屏,大概率是JS初始化时出错,但Metro日志未显示。可以通过以下方式查看:
- iOS模拟器中按Cmd+D打开开发者菜单,选择"Debug Remote JS",在Chrome开发者工具的Console标签查看错误
- Expo Go中打开开发者菜单,选择"Show Logs"查看原生和JS层面的日志
4. 检查第三方库兼容性
部分第三方库版本可能与Expo 44不兼容:
@stripe/stripe-react-native0.2.3版本较老,确认其是否支持Expo 44moti0.18.0依赖react-native-reanimated 2.x,当前版本2.3.1虽兼容,但可尝试升级到Expo 44支持的最新reanimated版本- 检查
expo-updates配置是否正确,错误的更新配置可能导致应用卡在闪屏
5. 对比空白Expo项目测试
创建空白Expo 44项目,测试能否正常运行:
expo init TestProject --template blank@44 cd TestProject expo start -c
如果空白项目能正常运行,说明问题出在当前项目的配置或依赖;如果也卡住,可能是Expo 44与最新环境的兼容性问题,可尝试升级到Expo 45或更高版本(注意备份项目)
内容的提问来源于stack exchange,提问作者chase-robbins
相关产品推荐
相关产品推荐

