shadcn-ui/ui · error · Error
Invalid configuration found in ${highlighter.info(componentP
Error message
Invalid configuration found in ${highlighter.info(componentPath)}. What it means
Thrown by the catch block of getRawConfig when parsing components.json fails for any reason other than the reserved-registry case. rawConfigSchema.parse runs a zod schema over the file contents; on failure (or any other thrown error whose message does not include "reserved registry"), the error is rethrown as a generic invalid-configuration message pointing at the components.json path.
Source
Thrown at packages/shadcn/src/utils/get-config.ts:223
// Check if user is trying to override built-in registries
if (config.registries) {
for (const registryName of Object.keys(config.registries)) {
if (registryName in BUILTIN_REGISTRIES) {
throw new Error(
`"${registryName}" is a built-in registry and cannot be overridden.`
)
}
}
}
return config
} catch (error) {
const componentPath = `${cwd}/components.json`
if (error instanceof Error && error.message.includes("reserved registry")) {
throw error
}
throw new Error(
`Invalid configuration found in ${highlighter.info(componentPath)}.`
)
}
}
// Note: we can check for -workspace.yaml or "workspace" in package.json.
// Since cwd is not necessarily the root of the project.
// We'll instead check if ui aliases resolve to a different root.
export async function getWorkspaceConfig(config: Config) {
let resolvedAliases: any = {}
for (const key of Object.keys(config.aliases)) {
if (!isAliasKey(key, config)) {
continue
}
const resolvedPath = config.resolvedPaths[key]
const packageRoot = await findPackageRoot(View on GitHub (pinned to efac598707)
Solutions
- Open components.json and check required fields: "$schema", "style", "rsc", "tsx", "tailwind" (config + css), "aliases" (components, utils, ui, lib, hooks), "iconLibrary".
- Compare against a known-good config from `npx shadcn@latest init` in a fresh project.
- Run `npx shadcn@latest init` to regenerate a valid components.json.
- If you need the underlying zod error detail, temporarily call rawConfigSchema.parse on the parsed JSON to see field-level issues.
Example fix
// components.json (before) — missing style + aliases
{ "$schema": "...", "rsc": true }
// after
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": { "config": "tailwind.config.ts", "css": "app/globals.css", "baseColor": "neutral" },
"aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" },
"iconLibrary": "lucide"
} Defensive patterns
Strategy: try-catch
Validate before calling
import { rawConfigSchema } from "@shadcn/schema"
const parsed = rawConfigSchema.safeParse(configJson)
if (!parsed.success) {
throw new Error(`invalid components.json: ${parsed.error.message}`)
} Type guard
const isRawConfig = (v: unknown): v is RawConfig => rawConfigSchema.safeParse(v).success
Try / catch
try {
await getRawConfig(cwd)
} catch (e) {
if (e instanceof Error && /Invalid configuration found/.test(e.message)) {
// call rawConfigSchema.parse directly to surface zod details
}
throw e
} Prevention
- Generate components.json via `npx shadcn@latest init`.
- Keep the $schema field pointing at the current schema URL for editor validation.
- Validate components.json against rawConfigSchema in CI.
- Avoid hand-editing required fields without consulting the schema.
When it happens
Trigger: cosmiconf explorer.search(cwd) finds components.json, but rawConfigSchema.parse throws a ZodError (missing required fields, wrong types, unknown style, etc.), or another error occurs. The catch swallows the detail and throws this generic message.
Common situations: components.json missing required fields (style, tailwind, aliases); typo in a field name; wrong TypeScript style value; leftover field from an old shadcn version; JSON syntax error that cosmiconf still parsed loosely.
Related errors
- INVALID_CONFIG
- "${registryName}" is a built-in registry and cannot be overr
- Invalid base: ${String(resolvedBase)}. Expected one of: ${PR
- Unknown preset: ${presetArg}
- Unknown client: ${client}. Available clients: ${CLIENTS.map(
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/05c8615ecbf5e4ac.
Report an issue: GitHub.