{"record":{"id":"61ca54addf357cb6","repo":"sveltejs/kit","slug":"server-files-not-found-at-dir-did-you-run-bui","errorCode":null,"errorMessage":"Server files not found at ${dir}, did you run `build` first?","messagePattern":"Server files not found at (.+?), did you run `build` first\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/vite/preview/index.js","lineNumber":32,"sourceCode":"import { stackless } from '../../../utils/error.js';\n\n/**\n * @param {PreviewServer} vite\n * @param {ValidatedConfig} svelte_config\n */\nexport async function preview(vite, svelte_config) {\n\tconst { paths } = svelte_config;\n\tconst base = paths.base;\n\tconst assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;\n\n\tconst protocol = vite.config.preview.https ? 'https' : 'http';\n\n\tconst etag = `\"${Date.now()}\"`;\n\n\tconst dir = join(svelte_config.outDir, 'output/server');\n\n\tif (!fs.existsSync(`${dir}/manifest.js`)) {\n\t\tthrow stackless(`Server files not found at ${dir}, did you run \\`build\\` first?`);\n\t}\n\n\tconst instrumentation = join(dir, 'instrumentation.server.js');\n\tif (fs.existsSync(instrumentation)) {\n\t\tawait import(pathToFileURL(instrumentation).href);\n\t}\n\n\t/** @type {ServerInternalModule} */\n\tconst { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href);\n\n\t/** @type {ServerModule} */\n\tconst { Server } = await import(pathToFileURL(join(dir, 'index.js')).href);\n\n\t/** @type {{ manifest: import('types').SSRManifest }} */\n\tconst { manifest } = await import(pathToFileURL(join(dir, 'manifest.js')).href);\n\n\tset_assets(assets);\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/vite/preview/index.js#L14-L50","documentation":"Startup check in the preview server: it expects the build output at outDir/output/server (with a manifest.js) to exist before it can serve a production preview. This stackless error fires when vite preview runs before vite build, or when outDir was customized so the built server lives elsewhere.","triggerScenarios":"Thrown at packages/kit/src/exports/vite/preview/index.js:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run `vite build` before `vite preview`","Ensure the preview outDir matches the build outDir in the SvelteKit/Vite config","Rebuild after changing config so output/server/manifest.js is regenerated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}