shadcn-ui/ui · error
Something went wrong reading your `components.json` file. Pl
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.
Source
Thrown at packages/shadcn/src/commands/migrate.ts:105
if (!options.migration) {
throw new Error(
"You must specify a migration. Run `shadcn migrate --list` to see available migrations."
)
}
let { errors, config } = await preFlightMigrate(options)
if (
errors[ERRORS.MISSING_DIR_OR_EMPTY_PROJECT] ||
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 === "radix") {
await migrateRadix(config, { yes: options.yes, path: options.path })
}
if (options.migration === "rtl") {View on GitHub (pinned to efac598707)
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
- Invalid base: ${String(resolvedBase)}. Expected one of: ${PR
- Unknown client: ${client}. Available clients: ${CLIENTS.map(
- You must specify a migration. Run `shadcn migrate --list` to
- No `components.json` file found. Ensure you are at the root
- File not found: ${options.path}
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/42a257ac230e8b92.
Report an issue: GitHub.