expo/expo · error · CommandError
expo export:web can only be used with Webpack. Use expo expo
Error message
expo export:web can only be used with Webpack. Use expo export for other bundlers.
What it means
Thrown by exportWebAsync when the resolved web bundler is not targeting web via Webpack. The function first asserts the Webpack prerequisite, builds a WebpackBundlerDevServer, then calls isTargetingWeb() — if the project's config sets web.bundler to 'metro' (or otherwise does not target webpack), the dedicated `expo export:web` command is the wrong entry point and the error redirects the user to `expo export`.
Source
Thrown at packages/@expo/cli/src/export/web/exportWebAsync.ts:22
import { Log } from '../../log';
import { WebSupportProjectPrerequisite } from '../../start/doctor/web/WebSupportProjectPrerequisite';
import { getPlatformBundlers } from '../../start/server/platformBundlers';
import { WebpackBundlerDevServer } from '../../start/server/webpack/WebpackBundlerDevServer';
import { CommandError } from '../../utils/errors';
import type { Options } from './resolveOptions';
export async function exportWebAsync(projectRoot: string, options: Options) {
// Ensure webpack is available
await new WebSupportProjectPrerequisite(projectRoot).assertAsync();
const { exp } = getConfig(projectRoot);
const platformBundlers = getPlatformBundlers(projectRoot, exp);
// Create a bundler interface
const bundler = new WebpackBundlerDevServer(projectRoot, platformBundlers);
// If the user set `web.bundler: 'metro'` then they should use `expo export` instead.
if (!bundler.isTargetingWeb()) {
throw new CommandError(
chalk`{bold expo export:web} can only be used with Webpack. Use {bold expo export} for other bundlers.`
);
}
Log.log(`Exporting with Webpack...`);
// Bundle the app
await bundler.bundleAsync({
mode: options.dev ? 'development' : 'production',
clear: options.clear,
});
}
View on GitHub (pinned to b09195aac2)
Solutions
- Use `expo export -p web` (or `expo export`) instead of `expo export:web` when the project uses Metro for web.
- If you intentionally want Webpack, set `web.bundler: 'webpack'` in app config and ensure webpack dependencies are installed.
- Remove the `web.bundler` override so it defaults appropriately for your SDK version.
Example fix
// before: app.config.js — web.bundler set to metro
module.exports = { expo: { web: { bundler: 'metro' } } };
# CLI
expo export:web # throws
// after
module.exports = { expo: { web: { bundler: 'webpack' } } };
# or simply use:
expo export -p web Defensive patterns
Strategy: validation
Validate before calling
import { getConfig } from '@expo/config';
const { exp } = getConfig(projectRoot);
const webBundler = exp.web?.bundler ?? 'metro'; // default depends on SDK
if (webBundler === 'metro') {
// use `expo export -p web`, NOT `expo export:web`
} Type guard
function shouldUseExportWebCommand(exp: any): boolean {
return exp?.web?.bundler === 'webpack';
} Prevention
- Default to `expo export -p web` for SDK 50+.
- Only use `expo export:web` when the project is explicitly configured for webpack.
When it happens
Trigger: Running `expo export:web` in a project whose app config has `web.bundler: 'metro'` (or no webpack setup that makes isTargetingWeb() true). WebSupportProjectPrerequisite may pass, but the bundler-targeting check fails.
Common situations: A project migrated to Metro for web (Expo SDK 50+ default) where the developer runs the legacy `expo export:web` command out of habit. Mixing webpack-specific tooling in a metro-web project.
Related errors
- Cannot find module '${moduleIdHint}'
- Cannot find module
- The experimental Metro feature `require.context` is not enab
- The experimental Metro feature `require.context` is not enab
- require.resolveWeak cannot be called dynamically. Ensure you
AI-assisted analysis of expo/expo@b09195aac2 (2026-08-12).
Data as JSON: /api/errors/53a05b699abed6ec.
Report an issue: GitHub.