{"record":{"id":"42a257ac230e8b92","repo":"shadcn-ui/ui","slug":"something-went-wrong-reading-your-components-json","errorCode":null,"errorMessage":"Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.","messagePattern":"Something went wrong reading your `components\\.json` file\\. Please ensure you have a valid `components\\.json` file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/commands/migrate.ts","lineNumber":105,"sourceCode":"      if (!options.migration) {\n        throw new Error(\n          \"You must specify a migration. Run `shadcn migrate --list` to see available migrations.\"\n        )\n      }\n\n      let { errors, config } = await preFlightMigrate(options)\n\n      if (\n        errors[ERRORS.MISSING_DIR_OR_EMPTY_PROJECT] ||\n        errors[ERRORS.MISSING_CONFIG]\n      ) {\n        throw new Error(\n          \"No `components.json` file found. Ensure you are at the root of your project.\"\n        )\n      }\n\n      if (!config) {\n        throw new Error(\n          \"Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.\"\n        )\n      }\n\n      if (options.migration === \"icons\") {\n        await migrateIcons(config, {\n          from: options.from,\n          to: options.to,\n          path: options.path,\n          yes: options.yes,\n        })\n      }\n\n      if (options.migration === \"radix\") {\n        await migrateRadix(config, { yes: options.yes, path: options.path })\n      }\n\n      if (options.migration === \"rtl\") {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/commands/migrate.ts#L87-L123","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (components.json — trailing comma)\n{\n  \"$schema\": \"https://ui.shadcn.com/schema.json\",\n  \"style\": \"new-york\",\n  \"tailwind\": { \"baseColor\": \"neutral\", \"cssVariables\": true, }\n}\n// after\n{\n  \"$schema\": \"https://ui.shadcn.com/schema.json\",\n  \"style\": \"new-york\",\n  \"tailwind\": { \"baseColor\": \"neutral\", \"cssVariables\": true }\n}","handlingStrategy":"validation","validationCode":"import fs from \"fs-extra\"\nimport { z } from \"zod\"\n\nconst ComponentsJsonSchema = z.object({\n  $schema: z.string().optional(),\n  style: z.string(),\n  tailwind: z.object({\n    baseColor: z.string(),\n    cssVariables: z.boolean(),\n  }),\n})\n\nasync function parseComponentsJson(p: string) {\n  const raw = await fs.readJson(p)            // throws on JSON syntax error\n  return ComponentsJsonSchema.parse(raw)      // throws on schema error\n}","typeGuard":"import { z } from \"zod\"\n\nconst ComponentsJsonSchema = z.object({\n  style: z.string(),\n  tailwind: z.object({ baseColor: z.string(), cssVariables: z.boolean() }),\n})\n\nfunction isValidComponentsJson(raw: unknown) {\n  return ComponentsJsonSchema.safeParse(raw).success\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit components.json without a JSON validator.","Commit a known-good components.json so you can revert on breakage."],"tags":["config","json","validation","migrate"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}