{"record":{"id":"008d5b6cfa12f048","repo":"sveltejs/kit","slug":"multiple-item-kind-layout-module-files-found-in","errorCode":null,"errorMessage":"Multiple ${item.kind} layout module files found in ${routes_base}${route.id} : ${path.basename(existing_file)} and ${file.name}","messagePattern":"Multiple (.+?) layout module files found in (.+?)(.+?) : (.+?) and (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/create_manifest_data/index.js","lineNumber":332,"sourceCode":"\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.layout.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.layout.parent_id = item.uses_layout;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!route.leaf) {\n\t\t\t\t\t\t\troute.leaf = { depth };\n\t\t\t\t\t\t} else if (route.leaf.component) {\n\t\t\t\t\t\t\tthrow duplicate_files_error('page component', route.leaf.component);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\troute.leaf.component = project_relative;\n\t\t\t\t\t\tif (item.uses_layout !== undefined) route.leaf.parent_id = item.uses_layout;\n\t\t\t\t\t}\n\t\t\t\t} else if (item.is_layout) {\n\t\t\t\t\tif (!route.layout) {\n\t\t\t\t\t\troute.layout = { depth, child_pages: [] };\n\t\t\t\t\t} else if (route.layout[item.kind]) {\n\t\t\t\t\t\tthrow duplicate_files_error(\n\t\t\t\t\t\t\titem.kind + ' layout module',\n\t\t\t\t\t\t\t/** @type {string} */ (route.layout[item.kind])\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\troute.layout[item.kind] = project_relative;\n\t\t\t\t} else if (item.is_page) {\n\t\t\t\t\tif (!route.leaf) {\n\t\t\t\t\t\troute.leaf = { depth };\n\t\t\t\t\t} else if (route.leaf[item.kind]) {\n\t\t\t\t\t\tthrow duplicate_files_error(\n\t\t\t\t\t\t\titem.kind + ' page module',\n\t\t\t\t\t\t\t/** @type {string} */ (route.leaf[item.kind])\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\troute.leaf[item.kind] = project_relative;\n\t\t\t\t} else {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/create_manifest_data/index.js#L314-L350","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Delete the redundant layout module file (keep either +layout.js or +layout.ts, not both)","Merge any differing logic (load, prerender, csr exports) from the deleted file into the kept one","Re-run sync and confirm the error is gone"],"exampleFix":"# before\nsrc/routes/+layout.js\nsrc/routes/+layout.ts\n\n# after (merged into one)\nsrc/routes/+layout.ts","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nconst dir = 'src/routes/about';\nif (existsSync(`${dir}/+layout.js`) && existsSync(`${dir}/+layout.ts`)) {\n  throw new Error('duplicate layout module: keep only +layout.js or +layout.ts');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never keep +layout.js and +layout.ts together","Delete the old module when migrating JS to TS","Check with a glob (`**/+layout.{js,ts}`) before committing"],"tags":["routing","typescript","duplicate-files"],"backgroundTag":"duplicate-route-file","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}