sveltejs/kit · error · Error

Multiple ${item.kind} layout module files found in ${routes_

Error message

Multiple ${item.kind} layout module files found in ${routes_base}${route.id} : ${path.basename(existing_file)} and ${file.name}

What it means

Each route may have at most one layout module of a given kind (+layout.js or +layout.ts — item.kind). If walk finds two layout module files of the same kind resolving to the same route, it throws duplicate_files_error('<kind> layout module', existing).

Source

Thrown at packages/kit/src/core/sync/create_manifest_data/index.js:332

						}

						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]) {
						throw duplicate_files_error(
							item.kind + ' layout module',
							/** @type {string} */ (route.layout[item.kind])
						);
					}

					route.layout[item.kind] = project_relative;
				} else if (item.is_page) {
					if (!route.leaf) {
						route.leaf = { depth };
					} else if (route.leaf[item.kind]) {
						throw duplicate_files_error(
							item.kind + ' page module',
							/** @type {string} */ (route.leaf[item.kind])
						);
					}

					route.leaf[item.kind] = project_relative;
				} else {

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Delete the redundant layout module file (keep either +layout.js or +layout.ts, not both)
  2. Merge any differing logic (load, prerender, csr exports) from the deleted file into the kept one
  3. Re-run sync and confirm the error is gone

Example fix

# before
src/routes/+layout.js
src/routes/+layout.ts

# after (merged into one)
src/routes/+layout.ts
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
const dir = 'src/routes/about';
if (existsSync(`${dir}/+layout.js`) && existsSync(`${dir}/+layout.ts`)) {
  throw new Error('duplicate layout module: keep only +layout.js or +layout.ts');
}

Prevention

When it happens

Trigger: Both `+layout.js` and `+layout.ts` (or similarly same-kind duplicates) exist in the same route directory, producing two candidate layout module files for one kind.

Common situations: Incremental JS-to-TS migration leaving both +layout.js and +layout.ts; copying files between branches; editor/backup copies like +layout.ts.bak misnamed into a valid extension.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/008d5b6cfa12f048. Report an issue: GitHub.