sveltejs/kit · error · Error
Could not find server asset ${file}
Error message
Could not find server asset ${file} What it means
adapter-bun embeds server assets (files listed in the server build manifest that must be served at runtime) by matching each asset path against an index of emitted build artifacts. When a server asset recorded in the manifest has no corresponding emitted artifact, this error is thrown.
Source
Thrown at packages/adapter-bun/index.js:337
throw new Error(`Could not find prerendered page ${file} for route ${path}`);
return entry(page, 'prerendered_page', path);
}),
...pr_pages
.filter(({ rel }) => !page_rels.has(rel))
.map((file) => entry(file, 'prerendered_asset')),
...[...pr_deps, ...pr_data].map((file) => entry(file, 'prerendered_asset'))
]);
const index_by_rel = new Map(
assets.map(({ rel }, i) => /** @type {[string, number]} */ ([rel, i])).reverse()
);
return {
imports,
entries,
server_assets: server_assets.map((file) => {
const idx = index_by_rel.get(file);
if (idx === undefined) throw new Error(`Could not find server asset ${file}`);
return `[${JSON.stringify(file)}, server_asset(${JSON.stringify(file)}, asset_${idx})]`;
})
};
}
/**
* @param {object} options
* @param {Builder} options.builder
* @param {string[]} options.server_assets
* @param {string} options.out
* @param {boolean} options.precompress
* @returns {Promise<{imports: string[], entries: string[], server_assets: string[]}>}
*/
async function get_no_embed_entries({ builder, server_assets, out, precompress }) {
const client_files = builder.writeClient(`${out}/client`).filter((file) => !is_dotfile(file));
const prerendered_files = builder.writePrerendered(`${out}/prerendered`);
validate_file_paths([...client_files, ...prerendered_files]);
View on GitHub (pinned to 03f1687fe6)
Solutions
- Clean and rebuild: rm -rf build .svelte-kit then `bun run --bun build`.
- Ensure referenced server-side assets are inside the project and included in the build outputs (check the adapter's assets/out config).
- Verify the files actually exist at the referenced paths and haven't been renamed or gitignored.
- Update @sveltejs/adapter-bun and Bun, since manifest/artifact mismatches can be fixed upstream.
Example fix
// before
// adapter config excludes the asset dir so the artifact is never emitted
// after
const config = {
kit: {
adapter: adapter({ assets: 'src/lib/server/assets' })
}
}; Defensive patterns
Strategy: validation
Validate before calling
// ensure every server asset has an emitted artifact before adapting
const indexByRel = new Map(artifacts.map((a, i) => [a.rel ?? a.path, i]));
for (const file of serverAssets) {
if (!indexByRel.has(file)) {
throw new Error(`Server asset ${file} was not emitted by the Bun build — check adapter assets config`);
}
} Type guard
const assetIsEmitted = (indexByRel, file) => indexByRel.has(file);
Try / catch
try {
await build();
} catch (e) {
if (/Could not find server asset/.test(e.message)) {
const file = /server asset (\S+)/.exec(e.message)?.[1];
console.error(`${file} missing from build outputs — include it in the build or fix the assets config, then rebuild.`);
process.exit(1);
}
throw e;
} Prevention
- Keep server-referenced assets inside directories included in the build
- Avoid gitignoring or moving assets mid-build
- Clean rebuild when the manifest and artifacts disagree
- Pin and update adapter-bun to get manifest-mismatch fixes
When it happens
Trigger: get_embed_entries maps the server_assets list through index_by_rel (built from emitted artifacts); the index lacks an entry for `file`, so the server_asset embedding line cannot be generated.
Common situations: Server-side referenced assets excluded from the Bun build outputs; misconfigured adapter assets option; stale build caches; assets moved/renamed between manifest generation and embedding.
Related errors
- Could not find prerendered page ${file} for route ${path}
- Cannot build with ${JSON.stringify(file)} because Bun treats
- Cannot build with ${JSON.stringify(file)} because Bun treats
- adapter-bun requires running the SvelteKit build with Bun. U
- ${log.message ?? String(log)}
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/0f63f6e4162bf35b.
Report an issue: GitHub.