sveltejs/kit · error · Error
Multiple layout component files found in ${routes_base}${rou
Error message
Multiple layout component files found in ${routes_base}${route.id} : ${path.basename(existing_file)} and ${file.name} What it means
SvelteKit's route scanner requires exactly one layout component per route directory. When create_manifest_data's walk finds a second +layout.svelte in the same route directory, it throws an error naming both conflicting files via duplicate_files_error('layout component', ...).
Source
Thrown at packages/kit/src/core/sync/create_manifest_data/index.js:313
function duplicate_files_error(type, existing_file) {
return new Error(
`Multiple ${type} files found in ${routes_base}${route.id} : ${path.basename(
existing_file
)} and ${file.name}`
);
}
if (item.kind === 'component') {
if (item.is_error) {
route.error = {
depth,
component: project_relative
};
} else if (item.is_layout) {
if (!route.layout) {
route.layout = { depth, child_pages: [] };
} else if (route.layout.component) {
throw duplicate_files_error('layout component', route.layout.component);
}
route.layout.component = project_relative;
if (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout;
} else {
if (!route.leaf) {
route.leaf = { depth };
} else if (route.leaf.component) {
throw duplicate_files_error('page component', route.leaf.component);
}
route.leaf.component = project_relative;
if (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout;
}
} else if (item.is_layout) {
if (!route.layout) {
route.layout = { depth, child_pages: [] };
} else if (route.layout[item.kind]) {View on GitHub (pinned to 03f1687fe6)
Solutions
- Remove one of the conflicting layout component files in that route directory
- If you intended a named layout, ensure it lives in a different directory or rename so only one layout component remains per route
- Re-run `vite dev`/`svelte-kit sync` after cleanup to confirm the manifest builds
Example fix
# before src/routes/+layout.svelte src/routes/+layout@alt.svelte # after (keep one) src/routes/+layout.svelte
Defensive patterns
Strategy: validation
Validate before calling
import { readdirSync } from 'node:fs';
const files = readdirSync('src/routes', { recursive: true });
for (const dir of new Set(files.map((f) => f.split('/').slice(0, -1).join('/')))) {
const layouts = files.filter((f) => f.startsWith(dir) && /\+layout(@[^/]+)?\.svelte$/.test(f));
if (layouts.length > 1) throw new Error(`duplicate layout component in ${dir}: ${layouts}`);
} Prevention
- One +layout.svelte per route directory
- Search routes with a glob before adding layouts (e.g. `**/+layout*.svelte`)
- Add a lint script that fails on duplicate route files
When it happens
Trigger: Two layout component files resolve to the same route id, e.g. both `+layout.svelte` and `+layout@foo.svelte` (a named layout usage) present in one directory, or case-variant duplicates on case-insensitive filesystems.
Common situations: Copying a named-layout example (+layout@main.svelte) into a folder that already has +layout.svelte; merging branches that each added a layout; file renames that left an old layout behind.
Related errors
- Multiple page component files found in ${routes_base}${route
- Mismatched route config for ${route.id} — the +page and +ser
- No matcher found for parameter '${name}'${file ? ` in ${file
- Multiple ${item.kind} layout module files found in ${routes_
- Multiple ${item.kind} page module files found in ${routes_ba
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/d8c96c6f12f153e2.
Report an issue: GitHub.