{"record":{"id":"4b7c42cfd55bf6c2","repo":"sveltejs/kit","slug":"adapter-bun-requires-running-the-sveltekit-build-w","errorCode":null,"errorMessage":"adapter-bun requires running the SvelteKit build with Bun. Use `bun run --bun build`.","messagePattern":"adapter-bun requires running the SvelteKit build with Bun\\. Use `bun run --bun build`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/index.js","lineNumber":116,"sourceCode":"\t\t}\n\t}\n}\n\n/** @type {import('./index.js').default} */\nexport default function (opts = {}) {\n\tconst {\n\t\tout = 'build',\n\t\tenvPrefix = '',\n\t\tprecompress = false,\n\t\tserverOptions = {},\n\t\tbuildOptions = {}\n\t} = opts;\n\n\treturn {\n\t\tname: '@sveltejs/adapter-bun',\n\t\tasync adapt(builder) {\n\t\t\tif (typeof Bun === 'undefined') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'adapter-bun requires running the SvelteKit build with Bun. Use `bun run --bun build`.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfs.rmSync(out, { recursive: true, force: true });\n\n\t\t\tbuilder.log.minor('Building server');\n\n\t\t\tif (precompress && buildOptions.compile) {\n\t\t\t\tbuilder.log.warn(\n\t\t\t\t\t'precompress is ignored with buildOptions.compile: embedded assets are imported by identity path'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst server = builder.getServerDirectory();\n\n\t\t\tconst src_dir = path.resolve(import.meta.dirname, 'src');\n\t\t\tconst index_file = path.resolve(src_dir, 'index.js');","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/index.js#L98-L134","documentation":"adapter-bun's adapt step relies on Bun-specific APIs (the global Bun object) to build its output. If the build is executed with Node.js instead of Bun, the global is undefined and the adapter throws immediately before producing any output.","triggerScenarios":"Running `vite build` / `npm run build` with Node as the runtime so `typeof Bun === 'undefined'` inside adapt(builder).","commonSituations":"CI configured with a Node setup step and no Bun runtime; running the default npm script instead of the Bun one; Bun not installed locally.","solutions":["Run the build with Bun: `bun run --bun build` (or `bun --bun vite build`).","Install Bun first: curl -fsSL https://bun.sh/install | bash, then rerun the build.","In CI, use a Bun setup action (oven-sh/setup-bun) before the build step.","Use adapter-node instead if you intend to build and run with Node."],"exampleFix":"// before\nnpm run build   // runs vite build under Node\n// after\nbun install\nbun run --bun build","handlingStrategy":"validation","validationCode":"if (typeof Bun === 'undefined') {\n  throw new Error('This project builds with adapter-bun — run `bun run --bun build` instead of npm/node.');\n}","typeGuard":"const isBunRuntime = () => typeof globalThis.Bun !== 'undefined';","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/requires running the SvelteKit build with Bun/.test(e.message)) {\n    console.error('Rerun with: bun run --bun build');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Add a runtime check to the build script so Node builds fail fast","Use oven-sh/setup-bun in CI before building","Document `bun run --bun build` as the canonical build command","Choose adapter-node if the team builds with Node"],"tags":["bun","runtime","adapter-bun","build"],"backgroundTag":"wrong-runtime-environment","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}