{"record":{"id":"41ec0355a2958e45","repo":"shadcn-ui/ui","slug":"could-not-resolve-the-following-aliases-in-highl","errorCode":null,"errorMessage":"Could not resolve the following aliases in ${highlighter.info(cwd)}: ${highlighter.info(missingAliases.join(\", \"))}.\nConfigure path aliases in ${highlighter.info(\"tsconfig.json\")} or imports in ${highlighter.info(\"package.json\")} for this workspace and try again.","messagePattern":"Could not resolve the following aliases in (.+?): (.+?)\\.\nConfigure path aliases in (.+?) or imports in (.+?) for this workspace and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/utils/get-config.ts","lineNumber":180,"sourceCode":"  return resolved.path\n}\n\nfunction assertResolvedAliases(\n  cwd: string,\n  resolvedAliases: Record<\n    \"components\" | \"utils\" | \"ui\" | \"lib\" | \"hooks\",\n    string | null\n  >\n) {\n  const missingAliases = [\"components\", \"ui\", \"lib\", \"hooks\", \"utils\"].filter(\n    (key) => !resolvedAliases[key as keyof typeof resolvedAliases]\n  )\n\n  if (!missingAliases.length) {\n    return\n  }\n\n  throw new Error(\n    [\n      `Could not resolve the following aliases in ${highlighter.info(cwd)}: ${highlighter.info(\n        missingAliases.join(\", \")\n      )}.`,\n      `Configure path aliases in ${highlighter.info(\n        \"tsconfig.json\"\n      )} or imports in ${highlighter.info(\n        \"package.json\"\n      )} for this workspace and try again.`,\n    ].join(\"\\n\")\n  )\n}\n\nexport async function getRawConfig(\n  cwd: string\n): Promise<z.infer<typeof rawConfigSchema> | null> {\n  try {\n    const configResult = await explorer.search(cwd)","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/utils/get-config.ts#L162-L198","documentation":"Thrown by assertResolvedAliases when one or more of the required aliases (components, ui, lib, hooks, utils) resolve to null after resolveAliasPath consults tsconfig paths and package imports. shadcn needs all five alias roots to know where to write files, so any unresolved alias aborts config resolution.","triggerScenarios":"resolveConfigPaths calls resolveAliasPath for each alias; if the alias string is not found in tsconfig \"paths\", package.json \"imports\", or workspace exports, it returns null. assertResolvedAliases collects every null key and throws if the list is non-empty.","commonSituations":"Fresh project where tsconfig paths do not cover components/ui/lib/hooks/utils; components.json aliases reference a prefix that was never declared; switched from paths to package \"imports\" but did not wire them; monorepo where the alias resolves only in a different package.","solutions":["Open tsconfig.json and add/fix the \"paths\" entries for each alias listed in the message (e.g. \"@/components/*\", \"@/lib/utils\", \"@/hooks/*\").","Or add matching \"imports\" entries in package.json if you use subpath imports.","Re-run `npx shadcn@latest init` to regenerate components.json aliases against the fixed tsconfig.","Verify the alias prefixes in components.json match the tsconfig paths exactly."],"exampleFix":"// tsconfig.json (before)\n{ \"compilerOptions\": { \"paths\": { \"@/*\": [\"./src/*\"] } } }\n// components.json references aliases that don't resolve -> error\n// after — ensure each alias resolves; e.g. add explicit paths\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@/*\": [\"./src/*\"],\n      \"@/components/*\": [\"./src/components/*\"],\n      \"@/lib/utils\": [\"./src/lib/utils\"],\n      \"@/hooks/*\": [\"./src/hooks/*\"]\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"import { loadConfig } from \"tsconfig-paths\"\nconst ts = await loadConfig(cwd)\nconst required = [\"components\", \"ui\", \"lib\", \"hooks\", \"utils\"]\nconst missing = required.filter((k) => !resolveAlias(config.aliases[k], ts))\nif (missing.length) throw new Error(`unresolved aliases: ${missing.join(\", \")}`)","typeGuard":"function aliasesResolve(config, ts): boolean {\n  return [\"components\", \"ui\", \"lib\", \"hooks\", \"utils\"].every((k) =>\n    !!resolveImportWithMetadata(config.aliases[k], { ...ts, cwd })?.path\n  )\n}","tryCatchPattern":"try {\n  await resolveConfigPaths(cwd, config)\n} catch (e) {\n  if (e instanceof Error && /Could not resolve the following aliases/.test(e.message)) {\n    // prompt to fix tsconfig paths\n  }\n  throw e\n}","preventionTips":["Run `npx shadcn@latest init` to generate matching aliases + tsconfig paths together.","Keep components.json alias prefixes in sync with tsconfig \"paths\".","In monorepos, ensure each package's tsconfig resolves all five aliases.","Use package.json \"imports\" consistently if you chose subpath imports."],"tags":["config","typescript","aliases","init"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}