{"record":{"id":"53a05b699abed6ec","repo":"expo/expo","slug":"expo-export-web-can-only-be-used-with-webpack-use","errorCode":null,"errorMessage":"expo export:web can only be used with Webpack. Use expo export for other bundlers.","messagePattern":"expo export:web can only be used with Webpack\\. Use expo export for other bundlers\\.","errorType":"exception","errorClass":"CommandError","httpStatus":null,"severity":"error","filePath":"packages/@expo/cli/src/export/web/exportWebAsync.ts","lineNumber":22,"sourceCode":"import { Log } from '../../log';\nimport { WebSupportProjectPrerequisite } from '../../start/doctor/web/WebSupportProjectPrerequisite';\nimport { getPlatformBundlers } from '../../start/server/platformBundlers';\nimport { WebpackBundlerDevServer } from '../../start/server/webpack/WebpackBundlerDevServer';\nimport { CommandError } from '../../utils/errors';\nimport type { Options } from './resolveOptions';\n\nexport async function exportWebAsync(projectRoot: string, options: Options) {\n  // Ensure webpack is available\n  await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n\n  const { exp } = getConfig(projectRoot);\n  const platformBundlers = getPlatformBundlers(projectRoot, exp);\n  // Create a bundler interface\n  const bundler = new WebpackBundlerDevServer(projectRoot, platformBundlers);\n\n  // If the user set `web.bundler: 'metro'` then they should use `expo export` instead.\n  if (!bundler.isTargetingWeb()) {\n    throw new CommandError(\n      chalk`{bold expo export:web} can only be used with Webpack. Use {bold expo export} for other bundlers.`\n    );\n  }\n\n  Log.log(`Exporting with Webpack...`);\n\n  // Bundle the app\n  await bundler.bundleAsync({\n    mode: options.dev ? 'development' : 'production',\n    clear: options.clear,\n  });\n}\n","sourceCodeStart":4,"sourceCodeEnd":35,"githubUrl":"https://github.com/expo/expo/blob/b09195aac27c9e4a63daaf12dcb6f00b6b2e08ee/packages/@expo/cli/src/export/web/exportWebAsync.ts#L4-L35","documentation":"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`.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: app.config.js — web.bundler set to metro\nmodule.exports = { expo: { web: { bundler: 'metro' } } };\n# CLI\nexpo export:web   # throws\n// after\nmodule.exports = { expo: { web: { bundler: 'webpack' } } };\n# or simply use:\nexpo export -p web","handlingStrategy":"validation","validationCode":"import { getConfig } from '@expo/config';\nconst { exp } = getConfig(projectRoot);\nconst webBundler = exp.web?.bundler ?? 'metro'; // default depends on SDK\nif (webBundler === 'metro') {\n  // use `expo export -p web`, NOT `expo export:web`\n}","typeGuard":"function shouldUseExportWebCommand(exp: any): boolean {\n  return exp?.web?.bundler === 'webpack';\n}","tryCatchPattern":null,"preventionTips":["Default to `expo export -p web` for SDK 50+.","Only use `expo export:web` when the project is explicitly configured for webpack."],"tags":["expo-cli","export","web","webpack","metro","bundler"],"backgroundTag":null,"analyzedSha":"b09195aac27c9e4a63daaf12dcb6f00b6b2e08ee","analyzedAt":"2026-08-12T15:59:58.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}