expo/expo · error · CommandError
BAD_ARGS
BAD_ARGS
Error message
Platform "${platform}" is not configured to use the Metro bundler in the project Expo config, or is missing from the supported platforms in the platforms array: [${configPlatforms.join(', ')}]. What it means
Thrown by assertPlatformBundler when the requested platform is not present in platformsAvailable (the platforms wired to the Metro bundler in the project's Expo config). It fires after the early 'no platforms' guard and the special web pass-through, so it specifically rejects a platform that is known but not enabled for Metro. The message also lists configPlatforms so the developer can see which platforms the project actually declares.
Source
Thrown at packages/@expo/cli/src/export/resolveOptions.ts:47
const platformsAvailable: Partial<PlatformBundlers> = Object.fromEntries(
Object.entries(platformBundlers).filter(
([platform, bundler]) => bundler === 'metro' && configPlatforms.includes(platform as Platform)
)
);
if (!Object.keys(platformsAvailable).length) {
throw new CommandError(
`No platforms are configured to use the Metro bundler in the project Expo config.`
);
}
const assertPlatformBundler = (platform: Platform): Platform => {
if (!platformsAvailable[platform]) {
if (!configPlatforms.includes(platform) && platform === 'web') {
// Pass through so the more robust error message is shown.
return platform;
}
throw new CommandError(
'BAD_ARGS',
`Platform "${platform}" is not configured to use the Metro bundler in the project Expo config, or is missing from the supported platforms in the platforms array: [${configPlatforms.join(
', '
)}].`
);
}
return platform;
};
const knownPlatforms = ['android', 'ios', 'web', 'tvos', 'macos'] as Platform[];
const assertPlatformIsKnown = (platform: string): Platform => {
if (!knownPlatforms.includes(platform as Platform)) {
throw new CommandError(
`Unsupported platform "${platform}". Options are: ${knownPlatforms.join(',')},all`
);
}
View on GitHub (pinned to b09195aac2)
Solutions
- Add the missing platform to the `platforms` array in app.json/app.config.js (e.g. platforms: ["android","ios","web"]).
- Verify the platform's bundler is set to 'metro' in the Expo config (getPlatformBundlers); for non-web platforms metro is the default unless overridden.
- Run with a platform that is already enabled, or use `-p all` to export every platform present in platformsAvailable.
- If exporting web specifically, use `expo export -p web` or the dedicated web export path rather than requesting web through the metro-only flow.
Example fix
// before: app.json
{ "expo": { "platforms": ["android"] } }
// after
{ "expo": { "platforms": ["android", "ios"] } } Defensive patterns
Strategy: validation
Validate before calling
// Before calling export/resolveOptions with a platform, ensure it is enabled for metro.
import { getConfig } from '@expo/config';
const { exp } = getConfig(projectRoot);
const configPlatforms = exp.platforms ?? [];
const platformBundlers = exp.platformBundlers ?? {}; // or use getPlatformBundlers
const isAvailable = configPlatforms.includes(platform) && platformBundlers[platform] === 'metro';
if (!isAvailable) {
throw new Error(`Enable ${platform} in app config platforms and assign it the metro bundler.`);
} Type guard
function isMetroPlatform(platform: string, configPlatforms: string[], platformBundlers: Record<string, string>): boolean {
return configPlatforms.includes(platform) && platformBundlers[platform] === 'metro';
} Try / catch
try {
await resolveOptions({ platform });
} catch (e) {
if (e instanceof CommandError && e.code === 'BAD_ARGS' && /not configured to use the Metro bundler/.test(e.message)) {
// prompt user to enable the platform in app config
} else throw e;
} Prevention
- Keep app config `platforms` in sync with the bundlers you actually target.
- Validate the requested platform against config before scripting exports.
- Use `-p all` to operate on every configured platform instead of guessing.
When it happens
Trigger: Calling an export/resolveOptions flow with a platform (e.g. 'ios' or 'tvos') that is absent from platformsAvailable, when the platform is not 'web' (web is passed through to a more robust error). platformsAvailable is built from getPlatformBundlers/config and the platform must be both in configPlatforms and assigned the Metro bundler.
Common situations: Running `expo export -p ios` in a project whose app.json omits 'ios' from the platforms array, or whose platform bundler is set to something other than metro. Configuring platforms: ['android','web'] and then requesting ios. Migrating a config and forgetting to re-enable a platform.
Related errors
- The experimental Metro feature `require.context` is not enab
- The experimental Metro feature `require.context` is not enab
- Unsupported platform "${platform}". Options are: ${knownPlat
- Cannot find module '${moduleIdHint}'
- Cannot find module
AI-assisted analysis of expo/expo@b09195aac2 (2026-08-12).
Data as JSON: /api/errors/3e27daa236767d42.
Report an issue: GitHub.