{"record":{"id":"de9197953bcbbd2a","repo":"sveltejs/kit","slug":"params-path-does-not-export-params-from-defi","errorCode":null,"errorMessage":"${params_path} does not export `params` from `defineParams`","messagePattern":"(.+?) does not export `params` from `defineParams`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/utils/params.js","lineNumber":57,"sourceCode":" *   root: string;\n *   load?: (file: string) => Promise<Record<string, unknown>>;\n * }} opts\n * @returns {Promise<Record<string, ParamMatcher> | null>}\n */\nexport async function load_and_validate_params({ routes, params_path, root, load }) {\n\tconst names = collect_matcher_names(routes);\n\n\tif (names.size === 0) return null;\n\n\tif (!params_path) {\n\t\tthrow new Error(`No matcher found for parameter '${names.values().next().value}'`);\n\t}\n\n\tconst file = path.resolve(root, params_path);\n\tconst module = load ? await load(file) : await import(pathToFileURL(file).href);\n\n\tif (!module.params || typeof module.params !== 'object') {\n\t\tthrow new Error(`${params_path} does not export \\`params\\` from \\`defineParams\\``);\n\t}\n\n\tvalidate_param_matchers(\n\t\t/** @type {Record<string, unknown>} */ (module.params),\n\t\tnames,\n\t\tparams_path\n\t);\n\n\treturn /** @type {Record<string, ParamMatcher>} */ (module.params);\n}\n","sourceCodeStart":39,"sourceCodeEnd":68,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/utils/params.js#L39-L68","documentation":"After loading the params module, SvelteKit validates that it exports a `params` object (produced by `defineParams`). This error is thrown when the module exists at `params_path` but does not export a `params` property that is an object, meaning the file was found but its shape is wrong.","triggerScenarios":"The module loaded from `params_path` (via `import` or the provided `load` function) either has no `params` export, exports `params` as null/false, or exports it as a non-object (e.g. a function or array from incorrect `defineParams` usage).","commonSituations":"Writing `export default defineParams({...})` instead of `export const params = defineParams({...})`; forgetting to call `defineParams` and exporting the raw object; pointing `params_path` at a random file that has nothing to do with params; stale build output or wrong root directory causing the wrong module to be imported.","solutions":["Export the matchers as `export const params = defineParams({...})` in the params file","Ensure `defineParams` is actually called (not just referenced) and returns the object","Verify `params_path` points at the correct file relative to the project root"],"exampleFix":"// before\nexport default defineParams({ integer: v.integer() });\n// after\nexport const params = defineParams({ integer: v.integer() });","handlingStrategy":"type-guard","validationCode":"const mod = await import(paramsFile);\nif (!mod.params || typeof mod.params !== 'object') {\n\tthrow new Error(`${paramsFile} must export const params = defineParams({...})`);\n}","typeGuard":"function exportsParams(mod) {\n\treturn mod !== null && typeof mod === 'object' && 'params' in mod && typeof mod.params === 'object' && mod.params !== null;\n}","tryCatchPattern":null,"preventionTips":["Always use the exact export shape: `export const params = defineParams({...})`","Never `export default` the matchers object","Point params_path at the file you actually edited; check relative-to-root resolution"],"tags":["routing","params","configuration","esm-exports"],"backgroundTag":"invalid-module-export","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}