{"record":{"id":"e25f877ed554c9bb","repo":"sveltejs/kit","slug":"invalid-alias-value-value","errorCode":null,"errorMessage":"Invalid alias value: ${value}","messagePattern":"Invalid alias value: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/sync/write_tsconfig/index.js","lineNumber":256,"sourceCode":" *\n * @param {import('types').ValidatedConfig} config\n * @param {string} root\n * @returns {Record<string, string[]>}\n */\nfunction get_paths(config, root) {\n\tconst alias = {\n\t\t...config.alias\n\t};\n\n\t/** @type {Record<string, string[]>} */\n\tconst paths = {};\n\n\tfor (const [key, value] of Object.entries(alias)) {\n\t\tconst key_match = alias_key.exec(key);\n\t\tif (!key_match) throw new Error(`Invalid alias key: ${key}`);\n\n\t\tconst value_match = alias_value.exec(value);\n\t\tif (!value_match) throw new Error(`Invalid alias value: ${value}`);\n\n\t\tconst resolved = path.resolve(root, remove_trailing_slashstar(value));\n\t\tconst slashstar = key_match[2];\n\n\t\tif (slashstar) {\n\t\t\tpaths[key] = [resolved + '/*'];\n\t\t} else {\n\t\t\tpaths[key] = [resolved];\n\t\t\tconst fileending = value_match[4];\n\n\t\t\tif (!fileending && !(key + '/*' in alias)) {\n\t\t\t\tpaths[key + '/*'] = [resolved + '/*'];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn paths;\n}","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/sync/write_tsconfig/index.js#L238-L274","documentation":"Each kit.alias value must be a plain relative path, optionally ending in `/*` or a file extension (alias_value = /^(.+?)((\\/\\*)|(\\.\\w+))?$/). Values like absolute paths with odd segments, URLs, or values with unsupported suffixes fail this regex, and sync throws before writing the tsconfig paths.","triggerScenarios":"kit.alias values such as 'https://example.com/lib', '/abs/path', './src/lib/', or 'src/lib.d' patterns that don't conform — anything not matching a relative path with optional /* or extension suffix.","commonSituations":"Copy-pasting alias values from webpack configs; accidentally adding trailing slashes; including protocol prefixes or leading './' variants that confuse the validation; typos in the path.","solutions":["Change the alias value to a simple relative path without a leading './' or trailing slash: 'src/lib' instead of './src/lib/'.","For wildcard aliases pair the key and value with `/*`: '$lib/*': 'src/lib/*'.","Remove non-path values (URLs, absolute paths) from kit.alias — aliases must point inside the project."],"exampleFix":"// before (svelte.config.js)\nalias: { '$utils': './src/utils/', '$cdn': 'https://cdn.example.com' }\n// after\nalias: { '$utils': 'src/utils', '$utils/*': 'src/utils/*' }","handlingStrategy":"validation","validationCode":"const ALIAS_VALUE = /^(.+?)((\\/\\*)|(\\.\\w+))?$/;\nfor (const value of Object.values(config.kit?.alias ?? {})) {\n  if (!ALIAS_VALUE.test(value)) throw new Error(`Invalid kit.alias value: ${value}`);\n}","typeGuard":"function isValidAliasValue(value) {\n  return typeof value === 'string' && value.length > 0 && /^(.+?)((\\/\\*)|(\\.\\w+))?$/.test(value);\n}","tryCatchPattern":"try {\n  await runSync();\n} catch (e) {\n  if (e.message.startsWith('Invalid alias value')) {\n    console.error('Fix kit.alias in svelte.config.js:', e.message);\n  }\n  throw e;\n}","preventionTips":["Alias values must be plain relative paths like 'src/lib' — no URLs, absolute paths, './' prefixes, or trailing slashes.","For wildcard mappings, mirror the key's /* in the value.","Validate svelte.config.js in CI before running sync/build."],"tags":["sveltekit","tsconfig","configuration","path-alias"],"backgroundTag":"invalid-alias-config","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}