首页 > 解决方案 > Expo React Native:预期版本范围:~6.0.0 - 实际安装版本:^5.0.1

问题描述

将 Expo SDK 33 更新到 34 后,我开始注意到几个 expo npm 包必须至少为 v6.0.0 的错误...

$ expo start -c
Starting project at /Users/nyxynyx/expoapp
Expo DevTools is running at http://localhost:19002

Some of your project's dependencies are not compatible with currently installed expo package version:
 - expo-ads-admob - expected version range: ~6.0.0 - actual version installed: ^5.0.1
 - expo-analytics-amplitude - expected version range: ~6.0.0 - actual version installed: ^5.0.1
 - expo-barcode-scanner - expected version range: ~6.0.0 - actual version installed: ^5.0.1
 - expo-permissions - expected version range: ~6.0.0 - actual version installed: ^5.0.1
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]

...

继续更新这些软件包

$ npm install --save expo-ads-admob expo-analytics-amplitude expo-barcode-scanner expo-permissions
npm WARN The package react-native-dotenv is included as both a dev and production dependency.

+ expo-permissions@5.0.1
+ expo-ads-admob@5.0.1
+ expo-analytics-amplitude@5.0.1
+ expo-barcode-scanner@5.0.1
updated 4 packages and audited 38421 packages in 5.052s
found 11 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

还尝试使用以下方法清除缓存:

rm -rf node_modules
npm cache clean
npm install
watchman watch-del-all 
rm -fr $TMPDIR/metro*
expo start -c

但是,存在关于需要 v6.0.0+ 的相同警告消息。该应用程序在 Expo iOS 客户端中运行正常(条形码扫描仪等)。我们应该做什么?

标签: node.jsreactjsreact-nativenpmexpo

解决方案


如果您正在使用Expo,我认为这不是安装它的正确方法。如果要从 安装自己的模块Expo,请使用此命令。

例子

expo install expo-ads-admob

推荐阅读