{"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/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/preview/index.ts#L45-L81","documentation":"Thrown by the preview command when the project requires server output (buildOutput !== 'static' or an adapter is otherwise expected) but no adapter is configured. Server-output previews delegate to the adapter's preview entrypoint, so without an adapter there is nothing to run.","triggerScenarios":"Running `astro preview` when settings.buildOutput is 'server' (any route is on-demand / prerender defaults to false) and settings.adapter is undefined. The check `if (!settings.adapter)` fires after the static branch.","commonSituations":"Setting output: 'server' (or prerender: false) without installing an adapter; removing the adapter integration from config but keeping server output; previewing an SSR project before `astro add node` (or another adapter).","solutions":["Install and add an adapter: `npx astro add node` (or @astrojs/vercel, @astrojs/cloudflare, etc.).","Ensure the adapter is listed under integrations or via the adapter config option in astro.config.","If you intended a static preview, set output: 'static' or prerender routes so buildOutput becomes static."],"exampleFix":"// before - astro.config.mjs has output: 'server', no adapter\n\n// after\nimport node from '@astrojs/node';\nexport default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }) });","handlingStrategy":"validation","validationCode":"// Ensure an adapter is configured for server output.\nimport { readFileSync } from 'node:fs';\nconst config = readFileSync('astro.config.mjs', 'utf8');\nif (/output:\\s*['\"]server['\"]/.test(config) && !/adapter\\s*:/.test(config)) {\n  throw new Error('Add an adapter: npx astro add node');\n}","typeGuard":"function hasAdapter(settings: { adapter?: unknown }): boolean {\n  return Boolean(settings.adapter);\n}","tryCatchPattern":null,"preventionTips":["Install an adapter (astro add node) when using output: 'server'.","Keep adapter and output config consistent.","Add a config check to CI for SSR projects."],"tags":["preview","adapter","ssr","config","cli"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}