{"record":{"id":"33b6f92369bb8c5d","repo":"shadcn-ui/ui","slug":"could-not-load-the-workspace-config-in-highlight","errorCode":null,"errorMessage":"Could not load the workspace config in ${highlighter.info(packageRoot)}.\nAdd ${highlighter.info(\"components.json\")} to this workspace and configure its path aliases or package imports, then try again.","messagePattern":"Could not load the workspace config in (.+?)\\.\nAdd (.+?) to this workspace and configure its path aliases or package imports, then try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/utils/get-config.ts","lineNumber":254,"sourceCode":"    if (!isAliasKey(key, config)) {\n      continue\n    }\n\n    const resolvedPath = config.resolvedPaths[key]\n    const packageRoot = await findPackageRoot(\n      config.resolvedPaths.cwd,\n      resolvedPath\n    )\n\n    if (!packageRoot) {\n      resolvedAliases[key] = config\n      continue\n    }\n\n    const workspaceConfig = await getConfig(packageRoot)\n\n    if (!workspaceConfig) {\n      throw new Error(\n        [\n          `Could not load the workspace config in ${highlighter.info(packageRoot)}.`,\n          `Add ${highlighter.info(\n            \"components.json\"\n          )} to this workspace and configure its path aliases or package imports, then try again.`,\n        ].join(\"\\n\")\n      )\n    }\n\n    resolvedAliases[key] = workspaceConfig\n  }\n\n  const result = workspaceConfigSchema.safeParse(resolvedAliases)\n  if (!result.success) {\n    return null\n  }\n\n  return result.data","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/utils/get-config.ts#L236-L272","documentation":"Thrown by getWorkspaceConfig when, for a resolved alias, findPackageRoot locates a package root but getConfig(packageRoot) returns no components.json config. In a monorepo, shadcn expects each package root that aliases point into to have its own components.json defining path aliases/imports.","triggerScenarios":"getWorkspaceConfig iterates alias keys; for each, findPackageRoot(config.cwd, resolvedPath) finds a package.json root; getConfig(packageRoot) returns null (no components.json there); the error fires for the first such package.","commonSituations":"Monorepo (pnpm/npm workspaces) where ui alias resolves into a workspace package that lacks components.json; partial monorepo setup where only the root has config; alias pointing at an external package root.","solutions":["Create a components.json in the package root named in the message.","In that components.json, configure the path aliases or package imports so the aliases resolve within that package.","Re-run the command; if multiple packages are flagged, repeat for each.","Alternatively, ensure the alias resolves within the root package so findPackageRoot returns null (skipping the workspace-config branch)."],"exampleFix":"# before — packages/ui has no components.json\n# after — create packages/ui/components.json\n{\n  \"$schema\": \"https://ui.shadcn.com/schema.json\",\n  \"style\": \"new-york\",\n  \"rsc\": true,\n  \"tsx\": true,\n  \"tailwind\": { \"config\": \"\", \"css\": \"styles/globals.css\", \"baseColor\": \"neutral\" },\n  \"aliases\": { \"components\": \"@/components\", \"utils\": \"@/lib/utils\", \"ui\": \"@/components/ui\", \"lib\": \"@/lib\", \"hooks\": \"@/hooks\" },\n  \"iconLibrary\": \"lucide\"\n}","handlingStrategy":"validation","validationCode":"import fsExtra from \"fs-extra\"\nasync function hasComponentsJson(pkgRoot: string): Promise<boolean> {\n  return fsExtra.pathExists(`${pkgRoot}/components.json`)\n}\nfor (const key of Object.keys(config.aliases)) {\n  const root = await findPackageRoot(config.resolvedPaths.cwd, config.resolvedPaths[key])\n  if (root && !(await hasComponentsJson(root))) {\n    throw new Error(`missing components.json in ${root}`)\n  }\n}","typeGuard":"const workspaceConfigExists = async (pkgRoot: string) =>\n  fsExtra.pathExists(`${pkgRoot}/components.json`)","tryCatchPattern":"try {\n  await getWorkspaceConfig(config)\n} catch (e) {\n  if (e instanceof Error && /Could not load the workspace config/.test(e.message)) {\n    // create components.json in the flagged packageRoot\n  }\n  throw e\n}","preventionTips":["In monorepos, add components.json to every package whose path an alias resolves into.","Keep each package's components.json aliases self-contained.","Run init inside each workspace package to scaffold configs.","Verify alias roots point within a package that has its own config."],"tags":["config","monorepo","workspace","init"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}