
When working with expo-updates
, you may encounter the following error:
checkForUpdateAsync()
is not supported in development builds.
This happens because expo-updates
only allows update checks in production builds (EAS Update or a standalone app). If you try to run checkForUpdateAsync()
in a development environment, it will fail.
In this guide, we’ll walk through the solution and explain how to prevent this error from occurring in your Expo project.
✅ Solution: Wrap the Update Check in a Production Check
To avoid calling checkForUpdateAsync()
in development, modify your function to check if the app is running in a production environment before executing the update logic.
Updated Code:
import * as Updates from 'expo-updates';
async function onFetchUpdateAsync() {
if (!Updates.isEmbeddedLaunch) {
console.log('Skipping update check in development mode.');
return;
}
try {
const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) {
await Updates.fetchUpdateAsync();
await Updates.reloadAsync();
}
} catch (error) {
console.log('debug: ', error);
}
}
How This Works:
Updates.isEmbeddedLaunch
returnsfalse
in development, so we preventcheckForUpdateAsync()
from running unless the app is in production.- This avoids unnecessary API calls and errors when running in dev mode.
๐ Alternative Solution: Use __DEV__
Another way to handle this issue is by using the __DEV__
flag, which is a built-in Expo variable that checks if the app is running in development mode.
Alternative Code:
if (__DEV__) {
console.log('Skipping update check in development mode.');
return;
}
Which Method Should You Use?
Updates.isEmbeddedLaunch
is Expo-specific and more accurate for determining if updates should run.__DEV__
is a general development flag that works across all JavaScript environments.- If you only want to restrict updates in Expo’s development mode, use
Updates.isEmbeddedLaunch
. - If you want a broader check (including debug mode in standalone apps), use
__DEV__
.
๐ Next Steps: Testing Updates in a Production-Like Environment
To test updates in an environment closer to production, follow these steps:
1️⃣ Run Expo with Production Flags
Instead of running expo start
, use the following command to mimic a production environment:
expo start --no-dev --minify
2️⃣ Deploy an Update with EAS Update
If you’re using EAS Update, deploy a new update by running:
eas update
This will push an update to your production users.
3️⃣ Ensure Updates Work in a Standalone Build
For standalone apps, Expo automatically checks for updates in production. You don’t need to manually trigger an update unless you want to force an update on demand.
๐ ️ Troubleshooting Tips
If you’re still facing issues:
- Double-check that you’re in the correct environment by logging
Updates.isEmbeddedLaunch
and__DEV__
values. - Ensure that your app is correctly configured for EAS Update by running:
expo diagnostics
- Verify that your Expo project is using the latest
expo-updates
version:
npm list expo-updates
- Check if your app.json is properly set up for updates:
"updates": { "enabled": true, "checkAutomatically": "ON_LOAD" }
๐ฏ Final Thoughts
By wrapping your checkForUpdateAsync()
function with a production check, you can prevent unnecessary errors while developing with Expo. Whether you use Updates.isEmbeddedLaunch
or __DEV__
, ensuring that update logic only runs in production will keep your development workflow smooth.
Have you encountered similar issues with Expo? Let me know in the comments! ๐