Versions drift after the first install: someone adds a package with npm install, or the project moves to a new SDK and every Expo package falls behind. Expo CLI compares the installed versions with the ones the SDK expects, and npx expo install can report and repair the differences. An SDK upgrade is built on that same repair, run in the right order.
Key terms
--check: thenpx expo installflag that lists installed packages whose versions need updating for the SDK.--fix: thenpx expo installflag that updates every invalid version automatically.expo.install.exclude: an array inpackage.jsonlisting packages that the version checks skip.- Expo Doctor: a tool, run with
npx expo-doctor, that checks a project for common problems and gives advice on fixing each one.
What the version check compares
The check covers the dependencies and devDependencies in package.json that appear in Expo's list of known versions, and it compares the versions actually installed in node_modules. How a package got there makes no difference: a version installed with npm install is checked the same as one installed with npx expo install. A package is flagged when its installed version doesn't satisfy the SDK's range. expo itself is the exception, flagged only when it is below the expected range.
npx expo start runs this check in the background and prints a summary such as 1 package may need updating. Run npx expo install --check for details. npx expo-doctor warns about mismatches too, and so does npx expo install when it installs a new version of a library. Setting EXPO_NO_DEPENDENCY_VALIDATION turns off the background check in npx expo start and the validation npx expo install runs while installing packages, for every package at once. npx expo install --check and --fix still check every package when it is set.
Reading and repairing the report
npx expo install --check prints each mismatch as the package, its installed version and the SDK's range, for example expo-camera@<installed> - expected version: ~58.0.14. In an interactive terminal it then asks Fix dependencies?. When the CI variable is set or the output isn't a TTY, it can't ask, so unfixed mismatches end the command with exit code 1 and "Found outdated dependencies". Add --json to get the list as JSON, again with exit code 1 when something is out of date. Naming packages limits the check to them: npx expo install expo-camera --check.
--fix skips the question and reinstalls each mismatched package at the version or range the SDK expects. If expo itself is behind, it installs expo first and then runs --fix again under the new version. The two flags can't be combined, and when nothing is out of date both print "Dependencies are up to date" and exit with code 0.
Keeping a version on purpose
--fix treats a newer release you installed deliberately like any other mismatch and moves it back into the SDK's range. When you want a different version than the one npx expo install recommends, list the package in expo.install.exclude, under the expo field of package.json, as in the package.json example, which leaves out every other field of the file.
Excluded packages are skipped by the version checks of npx expo install, npx expo-doctor and npx expo start, and --check and --fix print which ones they skipped. Unlike EXPO_NO_DEPENDENCY_VALIDATION, which applies to all packages at once, this leaves every other package checked. A bare package name stays excluded in every case. An entry with a version or range applies only while the SDK's suggestion matches it, so the warning comes back when the SDK's recommendation changes. Installing an excluded package without a version gets latest instead of the SDK's range.
Expo Doctor
Run npx expo-doctor in the project's root directory. It checks the app config and package.json for common issues, along with dependency compatibility, configuration files and the overall health of the project. For each problem it describes what's wrong and how to fix it, or where to find help. By default it also checks your packages against React Native Directory and warns about any that aren't listed there, which you can configure under expo.doctor.reactNativeDirectoryCheck in package.json. npx expo-doctor --help shows its usage.
Upgrading one SDK at a time
Upgrade one SDK version at a time, so that when something breaks you can pinpoint which upgrade caused it. Staying current also matters for Expo Go, which only supports the latest SDK: once a new SDK is released, the previous ones are no longer supported there.
The first three steps are also in the upgrade commands example:
- Install the new
expopackage withnpm install expo@^58.0.0, swapping in the range of the SDK you're targeting. - Run
npx expo install --fixto bring every dependency in line with the installed SDK, thennpx expo-doctorto check for common problems. - If you let Expo generate the
androidandiosdirectories withnpx expo prebuild(Continuous Native Generation) and they were generated for the previous SDK, delete them. They are generated again the next time you runnpx expo prebuildor build the app. If you maintain those directories by hand instead, follow the native steps in the upgrade walkthrough listed in the resources. - Read the release notes for the target SDK for breaking changes and extra instructions. SDK 58's are on the SDK 58 changelog.
Order matters in the first two steps: --fix matches packages to the expo version that is installed, so it only targets the new SDK once step 1 has run.
Code Examples
{
"expo": {
"install": {
"exclude": ["expo-camera"]
}
}
}# 1. Move the expo package to SDK 58
npm install expo@^58.0.0
# 2. Match every known package to the installed SDK, then check the project
npx expo install --fix
npx expo-doctor
# 3. Only if android and ios were generated for SDK 57: delete them
rm -rf android ios