sveltejs/kit · error · Error

Multiple ${item.kind} page module files found in ${routes_ba

Error message

Multiple ${item.kind} page 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 page module of a given kind (+page.js or +page.ts). When walk detects two same-kind page module files mapping to the same route id, it throws duplicate_files_error('<kind> page module', existing), listing both files.

Source

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

						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 {
					if (route.endpoint) {
						throw duplicate_files_error('endpoint', route.endpoint.file);
					}

					route.endpoint = {
						file: project_relative,
						page_options: null // will be filled later
					};
				}
			}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Remove the obsolete page module file (keep only +page.js or +page.ts per route)
  2. Port any load/exports from the removed file into the surviving one
  3. Re-run `vite dev` or `svelte-kit sync` to confirm route creation succeeds

Example fix

# before
src/routes/blog/+page.js
src/routes/blog/+page.ts

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

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: `+page.js` and `+page.ts` coexist in the same route directory (or another same-kind duplicate), so two page module files compete for one route.

Common situations: Converting +page.js to +page.ts without deleting the original; branch merges reintroducing the old module; generated or backup copies left in the routes tree.

Related errors


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