{"record":{"id":"24a5fe533a1d773f","repo":"withastro/astro","slug":"preview-no-adapter-found","errorCode":null,"errorMessage":"[preview] No adapter found.","messagePattern":"\\[preview\\] No adapter found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/preview/index.ts","lineNumber":63,"sourceCode":"\tsettings.buildOutput = getPrerenderDefault(settings.config) ? 'static' : 'server';\n\tawait createRoutesList({ settings: settings, cwd: inlineConfig.root }, logger);\n\n\tawait runHookConfigDone({ settings: settings, logger: logger, command: 'preview' });\n\n\tif (settings.buildOutput === 'static' && !settings.adapter?.previewEntrypoint) {\n\t\tconst clientOutDir = getClientOutputDirectory(settings);\n\t\tif (!fs.existsSync(clientOutDir)) {\n\t\t\tconst outDirPath = fileURLToPath(clientOutDir);\n\t\t\tthrow new Error(\n\t\t\t\t`[preview] The output directory ${outDirPath} does not exist. Did you run \\`astro build\\`?`,\n\t\t\t);\n\t\t}\n\t\tconst server = await createStaticPreviewServer(settings, logger);\n\t\treturn server;\n\t}\n\n\tif (!settings.adapter) {\n\t\tthrow new Error(`[preview] No adapter found.`);\n\t}\n\n\tif (!settings.adapter.previewEntrypoint) {\n\t\tthrow new Error(\n\t\t\t`[preview] The ${settings.adapter.name} adapter does not support the preview command.`,\n\t\t);\n\t}\n\t// We need to use require.resolve() here so that advanced package managers like pnpm\n\t// don't treat this as a dependency of Astro itself. This correctly resolves the\n\t// preview entrypoint of the integration package, relative to the user's project root.\n\tconst require = createRequire(settings.config.root);\n\tconst previewEntrypointUrl = pathToFileURL(\n\t\trequire.resolve(settings.adapter.previewEntrypoint.toString()),\n\t).href;\n\n\tconst previewModule = (await import(previewEntrypointUrl)) as Partial<PreviewModule>;\n\tif (typeof previewModule.default !== 'function') {\n\t\tthrow new Error(`[preview] ${settings.adapter.name} cannot preview your app.`);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/preview/index.ts#L45-L81","documentation":"When Astro resolves to server output (`output: 'server'` or any route not prerendered), `astro preview` cannot use the static file server and must delegate to an adapter's preview entrypoint. If no adapter is configured at all, there is no runtime to serve the app, so preview throws immediately after the static branch is skipped.","triggerScenarios":"Setting `output: 'server'` in astro.config without installing an adapter; running `astro preview` on an SSR project where `astro add <adapter>` was never run; defining the adapter in a different config file than the one Astro loads (e.g. a stale astro.config.mjs next to a new astro.config.ts); adapter added conditionally so it is undefined in this environment.","commonSituations":"Converting a static site to SSR and forgetting the adapter; adapter dependency present in package.json but never registered in the config; monorepo where the adapter is added to the wrong package's config.","solutions":["Install and register an adapter: `npx astro add node` (or vercel/netlify/cloudflare as appropriate)","If the site is actually static, set `output: 'static'` (or remove `output: 'server'`) so preview uses the static server","Confirm the astro.config file you edited is the one Astro loads (only one of astro.config.mjs/.ts/.js is used)","Rebuild after adding the adapter: `astro build && astro preview`"],"exampleFix":"// before — astro.config.mjs\nimport { defineConfig } from 'astro/config';\nexport default defineConfig({ output: 'server' });\n\n// after\nimport node from '@astrojs/node';\nexport default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }) });","handlingStrategy":"validation","validationCode":"// scripts/verify-preview.mjs — fail fast if SSR output has no adapter\nimport config from './astro.config.mjs';\nif ((config.output ?? 'static') === 'server' && !config.adapter) {\n  console.error('output: \\'server\\' requires an adapter for `astro preview` — run `npx astro add node`');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `npx astro add <adapter>` immediately when switching `output: 'server'`","Keep one config file (delete alternates) so the adapter registration is always the one Astro loads","Add a config smoke test in CI that asserts adapter presence for server output"],"tags":["preview","adapter","ssr","config","cli"],"backgroundTag":"missing-server-adapter","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}