shadcn-ui/ui · error
Something went wrong reading your `components.json` file…
Error message
Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.
What it means
components.json exists (so preFlightMigrate didn't flag MISSING_CONFIG) but getConfig could not parse it into a valid Config object, so `config` is null. Typically a JSON syntax error or a schema-validation failure.
Solutions
- Validate components.json with a JSON linter: `npx jsonlint components.json`.
- Diff against a known-good components.json produced by `shadcn init`.
- Re-run `shadcn init` to regenerate a valid file.
- Ensure required fields ($schema, style, tailwind, aliases, resolvedPaths) are present and correctly typed.
Example fix
// before (components.json — trailing comma)
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"tailwind": { "baseColor": "neutral", "cssVariables": true, }
}
// after
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"tailwind": { "baseColor": "neutral", "cssVariables": true }
} Defensive patterns
Strategy: validation
Validate before calling
import fs from "fs-extra"
import { z } from "zod"
const ComponentsJsonSchema = z.object({
$schema: z.string().optional(),
style: z.string(),
tailwind: z.object({
baseColor: z.string(),
cssVariables: z.boolean(),
}),
})
async function parseComponentsJson(p: string) {
const raw = await fs.readJson(p) // throws on JSON syntax error
return ComponentsJsonSchema.parse(raw) // throws on schema error
} Type guard
import { z } from "zod"
const ComponentsJsonSchema = z.object({
style: z.string(),
tailwind: z.object({ baseColor: z.string(), cssVariables: z.boolean() }),
})
function isValidComponentsJson(raw: unknown) {
return ComponentsJsonSchema.safeParse(raw).success
} Prevention
- Never hand-edit components.json without a JSON validator.
- Commit a known-good components.json so you can revert on breakage.
When it happens
Trigger: Running `shadcn migrate` when components.json is syntactically invalid JSON or fails schema validation inside getConfig — required fields missing, wrong types, unknown tailwind/aliases shape.
Common situations: Hand-edited components.json with a trailing comma, unquoted key, or comment; partial git merge leaving broken JSON; file truncated by a crashed editor; schema fields renamed across shadcn versions.
Related errors
- A full project config is required to resolve target aliases.
- File not found
- Invalid base: . Expected one of: .
- INVALID_CONFIG
- INVALID_CONFIG
AI-assisted analysis of shadcn-ui/ui@5c7072da67 (2026-08-12).
Data as JSON: /api/errors/42a257ac230e8b92.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shadcn/src/commands/migrate.ts:118
return
}
const { errors, config } = await preFlightMigrate(options)
if (errors[ERRORS.MISSING_DIR_OR_EMPTY_PROJECT]) {
throw new Error(
"No `components.json` file found. Ensure you are at the root of your project."
)
}
if (errors[ERRORS.MISSING_CONFIG]) {
throw new Error(
"No `components.json` file found. Ensure you are at the root of your project."
)
}
if (!config) {
throw new Error(
"Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file."
)
}
if (options.migration === "icons") {
await migrateIcons(config, {
from: options.from,
to: options.to,
path: options.path,
yes: options.yes,
})
}
if (options.migration === "base-color") {
await migrateBaseColor(config, {
from: options.from,
to: options.to,
yes: options.yes,View on GitHub (pinned to 5c7072da67)