sveltejs/kit · error · Error
Cannot build with ${JSON.stringify(file)} because Bun treats
Error message
Cannot build with ${JSON.stringify(file)} because Bun treats literal `*` characters in route paths as wildcards. Rename the file or route to remove the `*` character. What it means
adapter-bun emits route files into a Bun built-in HTTP router/manifest where a literal '*' in a path is interpreted as a wildcard, conflicting with SvelteKit's rest-route syntax (e.g. [...slug]). The adapter therefore rejects any generated route file path containing '*' at build time.
Source
Thrown at packages/adapter-bun/index.js:89
*/
async function asset_meta(file, precompress = false) {
const hash = await hash_file(file);
/** @type {{ hash: string, mtime: number, br?: boolean, gz?: boolean }} */
const meta = { hash, mtime: Bun.file(file).lastModified };
if (precompress) {
if (fs.existsSync(`${file}.br`)) meta.br = true;
if (fs.existsSync(`${file}.gz`)) meta.gz = true;
}
return meta;
}
/** @param {string[]} files */
function validate_file_paths(files) {
for (const file of files) {
if (file.includes('*')) {
throw new Error(
`Cannot build with ${JSON.stringify(file)} because Bun treats literal \`*\` characters in route paths as wildcards. Rename the file or route to remove the \`*\` character.`
);
}
// a leading ':' would need percent-encoding, but browsers request the colon raw
if (file.split('/').some((segment) => segment.startsWith(':'))) {
throw new Error(
`Cannot build with ${JSON.stringify(file)} because Bun treats a route segment starting with \`:\` as a parameter. Rename the file or route so no segment starts with \`:\`.`
);
}
}
}
/** @type {import('./index.js').default} */
export default function (opts = {}) {
const {
out = 'build',
envPrefix = '',
precompress = false,View on GitHub (pinned to 03f1687fe6)
Solutions
- Rename the route to avoid '*' — e.g. replace [...slug] with a fixed route or a named param [slug].
- Check for accidentally created files/folders with '*' in their name inside src/routes.
- Switch to an adapter without this restriction (e.g. adapter-node) if the wildcard route is required.
Example fix
// before src/routes/[...slug]/+page.svelte // after src/routes/[slug]/+page.svelte // or handle catch-alls with adapter-node
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
const offenders = [];
(function walk(dir) {
for (const f of fs.readdirSync(dir)) {
const p = path.join(dir, f);
if (fs.statSync(p).isDirectory()) walk(p);
else if (p.includes('*')) offenders.push(p);
}
})('src/routes');
if (offenders.length) throw new Error(`adapter-bun rejects '*' in route paths: ${offenders.join(', ')}`); Type guard
const isBunSafeRoute = (file) => !file.includes('*'); Try / catch
try {
await build();
} catch (e) {
if (/Bun treats literal `\*` characters in route paths/.test(e.message)) {
console.error('Rename the reported route file to remove the * character');
process.exit(1);
}
throw e;
} Prevention
- Avoid SvelteKit rest routes ([...slug]) when targeting adapter-bun
- Lint src/routes filenames for '*' before builds
- Document adapter-bun route naming restrictions in the repo
When it happens
Trigger: validate_file_paths was called (from get_embed_entries, get_no_embed_entries, or create_routes) and one of the generated route file paths, e.g. 'src/routes/[...slug]/+page.svelte', contains a '*' character.
Common situations: Using SvelteKit rest parameters like [...slug] or catch-all routes with adapter-bun; nested optional rest routes like [[...rest]].
Related errors
- Cannot build with ${JSON.stringify(file)} because Bun treats
- adapter-bun requires running the SvelteKit build with Bun. U
- ${log.message ?? String(log)}
- @sveltejs/adapter-bun requires Bun 1.4 or newer, but this is
- Could not find prerendered page ${file} for route ${path}
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/b047ebb53ab7b986.
Report an issue: GitHub.