Managing SDK Versions for Consistency
In this lesson, you will learn how to synchronize your Expo SDK version across different machines and your CI/CD pipeline to ensure your app behaves identically everywhere.
The "It Works on My Machine" Problem
When working in a team or using automated build services (like EAS Build), the biggest source of "silent bugs" is mismatched environment configurations. If your local machine uses Expo SDK 50, but your CI/CD server pulls the latest available version (perhaps SDK 51), you might encounter build failures or runtime crashes that are incredibly difficult to debug because the underlying native dependencies differ.
Locking Your Version
In the Expo ecosystem, the project's dependency on the SDK is defined in your package.json. To prevent your project from drifting, you must ensure that your expo package version and the supporting dependencies match the intended SDK release.
When you initialize an Expo project, the versions are defined clearly. To manage these, keep your package.json tracked in version control (like Git). Never rely on manually installing "latest" packages. Instead, use specific versions:
{
"dependencies": {
"expo": "~50.0.0",
"react-native": "0.73.6"
}
}
By using the tilde (~) or exact versions, you signal to your package manager (npm or yarn) that it should resolve the dependencies exactly as defined. When your CI/CD pipeline runs, it will read this package.json and the corresponding package-lock.json (or yarn.lock) to recreate the exact environment of your local machine.
Why This Matters for CI/CD
Your CI/CD pipeline should perform a "clean install." By running npm ci (or yarn install --frozen-lockfile), you force the server to respect the exact version tree generated on your development machine. This creates a "Source of Truth" that prevents the CI pipeline from upgrading your SDK behind your back, ensuring that the app you test locally is the exact same app that gets sent to the app stores.
Key Takeaway: Always commit your package.json and lock files to version control to lock your SDK version and prevent environment drift across development and production build pipelines.