{"record":{"id":"17cf18328d5176e2","repo":"sveltejs/kit","slug":"keypath-should-be-an-object","errorCode":null,"errorMessage":"${keypath} should be an object","messagePattern":"(.+?) should be an object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/options.js","lineNumber":58,"sourceCode":"\tif (typeof input === 'function') return input;\n\tif (['fail', 'warn', 'ignore'].includes(input)) return input;\n\tthrow new Error(`${keypath} should be \"fail\", \"warn\", \"ignore\" or a custom function`);\n});\n\nconst options = {\n\tadapter: validate(undefined, (input, keypath) => {\n\t\tif (typeof input !== 'object' || !input.adapt) {\n\t\t\tconst message = `The SvelteKit Vite plugin ${keypath} should be an object with an \\`adapt\\` method`;\n\t\t\tthrow new Error(`${message}. See https://svelte.dev/docs/kit/adapters`);\n\t\t}\n\n\t\treturn input;\n\t}),\n\n\talias: deprecate(\n\t\tvalidate({}, (input, keypath) => {\n\t\t\tif (typeof input !== 'object') {\n\t\t\t\tthrow new Error(`${keypath} should be an object`);\n\t\t\t}\n\n\t\t\tfor (const key in input) {\n\t\t\t\tassert_string(input[key], `${keypath}.${key}`);\n\t\t\t}\n\n\t\t\treturn input;\n\t\t}),\n\t\t(keypath) =>\n\t\t\t`The \\`${keypath}\\` option is deprecated, and will be removed in a future version of SvelteKit. Use subpath imports instead: https://svelte.dev/docs/kit/$lib`\n\t),\n\n\tappDir: validate('_app', (input, keypath) => {\n\t\tassert_string(input, keypath);\n\n\t\tif (input) {\n\t\t\tif (input.startsWith('/') || input.endsWith('/')) {\n\t\t\t\tthrow new Error(","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/options.js#L40-L76","documentation":"`kit.alias` must be a plain object mapping import aliases to file paths, where every value is a string. The validator throws the generic \"should be an object\" message when the value itself is not an object (string, array, function, etc.), and each entry's value is separately checked with assert_string.","triggerScenarios":"validate_options validates config.kit.alias and typeof input !== 'object' — e.g. `alias: '~/src'` (string) or `alias: ['~/lib']` (array).","commonSituations":"Confusing kit.alias with Vite's resolve.alias syntax; copying an array-style alias list from another tool (webpack loaders, tsconfig paths pasted as array); accidentally assigning the alias map at the wrong key.","solutions":["Change alias to an object form: `{ alias: { $lib: 'src/lib' } }`.","If you need advanced Vite alias semantics, configure them in vite.config's resolve.alias instead of kit.alias.","Ensure every alias value is a string path."],"exampleFix":"// before\nkit: { alias: ['@components:src/lib/components'] }\n// after\nkit: { alias: { '@components': 'src/lib/components' } }","handlingStrategy":"type-guard","validationCode":"const alias = config.kit?.alias;\nif (alias !== undefined && (typeof alias !== 'object' || Array.isArray(alias))) {\n  throw new Error('kit.alias must be a plain object of string paths');\n}","typeGuard":"/** @returns {alias is Record<string, string>} */\nfunction isAliasMap(alias) {\n  return typeof alias === 'object' && alias !== null && !Array.isArray(alias) &&\n    Object.values(alias).every((v) => typeof v === 'string');\n}","tryCatchPattern":"try {\n  await viteBuild();\n} catch (e) {\n  if (e.message.includes('should be an object')) {\n    console.error('kit.alias must be an object like { $lib: \"src/lib\" }');\n  }\n  throw e;\n}","preventionTips":["Use object syntax for kit.alias, not arrays or strings","Put advanced aliasing (regex, arrays) in vite.config resolve.alias instead","Ensure every alias value is a plain string path","Type the config with the exported Config type to catch this at edit time"],"tags":["config","validation","alias","type-mismatch"],"backgroundTag":"invalid-config-shape","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}