Adding a library to an Expo project starts with one command, and that command decides which version lands in package.json. React Native is not backwards compatible, so a package often has to be the exact version that matches the project's installed react-native. npx expo install does that matching for you, which is why Expo recommends it over npm install and yarn add for every package you add.
Key terms
npx expo install: the Expo CLI command that picks a version of a library compatible with your project, then runs your JavaScript package manager to install it.- SDK version: the Expo SDK a project targets, derived from the major version of the installed
expopackage. bundledNativeModules.json: a file shipped inside theexpopackage that maps known libraries to the version or range they should have for that SDK.
A version that fits the SDK
npx expo install doesn't install packages itself. It works out a version, then hands the install to npm, Yarn, pnpm or Bun. When it can, it picks a compatible version, and it warns you about incompatibilities it already knows about. It is a best-effort drop-in replacement for npm install. The compatible versions come from a list of popular packages and version combinations known to work together, and a package outside that list gets no version from Expo.
There is nothing to install globally. Expo CLI ships inside the expo package, so npx expo commands work in any project that has expo installed.
How Expo knows which version to pick
The SDK version comes from the expo package in node_modules. Expo reads its major version, so with expo at 58.x.y the project is on SDK 58. An sdkVersion set in the app config takes precedence. The app config is the project's Expo settings file, app.json in the default template, with its settings under the expo key, and the App Config section covers it. If expo isn't installed at all, Expo can't tell the SDK version and stops with an error telling you to install it.
With the SDK version known, Expo looks up the versions known to work with that SDK. The installed expo package ships a copy of that list as bundledNativeModules.json. In the SDK 58 map, expo-camera has the range ~58.0.14, while react and react-native are pinned to the exact versions 19.3.0 and 0.88.1.
Each package in your command then takes one of two paths:
- A package Expo knows, requested without a version, is rewritten to the SDK's range, so
npx expo install expo-cameraasks the package manager forexpo-camera@~58.0.14while that is the range in effect. - A package Expo has no version for goes to the package manager unchanged, and the package manager resolves its version as it normally would.
A version you write yourself always wins. Anything after the @ other than *, a tag such as expo-camera@latest included, counts as a specified version, and Expo installs exactly what you asked for instead of the SDK's range. For a package it knows, it prints that the version was explicitly provided.
Commands for everyday installs
Several packages can go in one command, as in npx expo install expo-camera react-native, and each one is resolved on its own path. For a tool you only need while developing, add --dev:
bashnpx expo install jest-expo --dev
With --dev, Expo calls the package manager's add-as-dev-dependency command instead of the normal add, so the package is saved under devDependencies.
Anything after a bare -- goes straight to the package manager. npx expo install expo-camera -- --verbose resolves expo-camera as usual and passes --verbose to the add command. The same operator can carry a dev flag, as in yarn expo install jest-expo -- -D, which runs yarn add with -D, but --dev does it without knowing each package manager's spelling.
The command finds the project root from the current directory, so you can also run it from a subfolder.
npm, Yarn, pnpm or Bun
npx expo install supports four package managers and chooses one from the lockfile in your project. A flag forces a specific one:
| Lockfile in the project | Package manager | Flag that forces it |
|---|---|---|
bun.lockb or bun.lock | Bun | --bun |
package-lock.json | npm | --npm |
pnpm-lock.yaml | pnpm | --pnpm |
yarn.lock | Yarn | --yarn |
Pass at most one of these flags. Two package manager flags in the same command are an error.
Code Examples
# expo-camera has a known range for the SDK, so Expo installs that range
npx expo install expo-camera
# Several packages in one command, each resolved separately
npx expo install expo-camera react-native
# A tag or version you write is installed as written
npx expo install expo-camera@latest
# Arguments after -- go to the package manager unchanged
npx expo install expo-camera -- --verbose
# Use pnpm even if another lockfile is present
npx expo install expo-camera --pnpm