Expo创建的React Native项目升级版本时遭遇依赖冲突、命令报错等问题求助
Expo创建的React Native项目升级版本时遭遇依赖冲突、命令报错等问题求助
我是个React Native新手,用Expo初始化的项目,现在想升级版本却遇到一堆问题,折腾好几天了实在搞不定,来求助大家!
我的项目环境
目前本地的版本信息:
- npm: 11.4.2
- Expo SDK: 53.0.19(
npm show expo version查询结果) - Expo CLI: 0.24.15(
npx expo --version查询结果) - Expo Router: 5.1.3
- Expo Go: 2.33.20
- React Native: 0.79.5(package.json里的版本)
- Node.js: v22.16
- 本地查询到的最新React Native版本:0.80.1(
npm view react-native结果)
核心困惑点&已踩的坑
1. 版本显示不一致的疑问
用npm view react-native查到最新版是0.80.1,但我的package.json里React Native版本是0.79.5,这是为什么?
2. 手动修改版本后的依赖冲突
我试着把package.json里的react-native改成0.80.1,结果装依赖(比如卸载重装react-native-maps时)直接爆一堆依赖冲突错误:
pierrot:~/Documents/GitHub/ReactN/iot-charts$ npm install react-native-maps npm error code ERESOLVE npm error ERESOLVE could not resolve npm error npm error While resolving: react-native@0.80.1 npm error Found: @types/react@19.0.14 npm error node_modules/@types/react npm error peerOptional @types/react@"" from @radix-ui/react-compose-refs@1.1.2 npm error node_modules/@radix-ui/react-compose-refs npm error @radix-ui/react-compose-refs@"1.1.2" from @radix-ui/react-slot@1.2.0 npm error node_modules/@radix-ui/react-slot npm error @radix-ui/react-slot@"1.2.0" from expo-router@5.1.3 npm error node_modules/expo-router npm error expo-router@"~5.1.3" from the root project npm error peerOptional @types/react@"" from @radix-ui/react-slot@1.2.0 npm error node_modules/@radix-ui/react-slot npm error @radix-ui/react-slot@"1.2.0" from expo-router@5.1.3 npm error node_modules/expo-router npm error expo-router@"~5.1.3" from the root project npm error 2 more (the root project, @react-native/virtualized-lists) npm error npm error Could not resolve dependency: npm error peerOptional @types/react@"^19.1.0" from react-native@0.80.1 npm error node_modules/react-native npm error react-native@"0.80.1" from the root project npm error peer react-native@"" from @expo/metro-runtime@5.0.4 npm error node_modules/@expo/metro-runtime npm error peerOptional @expo/metro-runtime@"" from expo@53.0.19 npm error node_modules/expo npm error peer expo@"" from expo-asset@11.1.7 npm error node_modules/expo-asset npm error 14 more (expo-blur, expo-constants, expo-file-system, expo-font, ...) npm error 1 more (expo-router) npm error 29 more (@expo/vector-icons, @react-navigation/bottom-tabs, ...) npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error For a full report see: npm error /Users/pierrot/.npm/_logs/2025-07-15T20_10_51_680Z-eresolve-report.txt npm error A complete log of this run can be found in: /Users/pierrot/.npm/_logs/2025-07-15T20_10_51_680Z-debug-0.log
但如果保持0.79.5版本,装依赖就完全没问题,这到底是哪里出问题了?
3. Upgrade Helper使用困惑
我找到了Upgrade Helper工具,但不知道具体该怎么操作。我大概懂要把package.json里的:
"react": "19.0.0"改成"react": "19.1.0""react-native": "0.79.5"改成"react-native": "0.80.1"
但工具里还有其他修改建议,比如提到要改android/gradlew文件,可我用Expo创建的项目根本没有android文件夹啊?接下来我该做什么?
4. 升级命令报错
我试着用npx react-native upgrade命令升级,先是报@react-native-community/cli相关错误,现在直接报:
error: unknown command 'upgrade'
而且我还看到有些教程说要重新装React Native,但我的package.json里明明已经有react-native依赖了,这又是为什么?
真的越搞越懵了,有没有大佬能帮我理清楚Expo项目到底该怎么正确升级React Native版本啊?
内容来源于stack exchange
相关产品推荐
相关产品推荐

