{"record":{"id":"e323b388f76ac15a","repo":"shadcn-ui/ui","slug":"no-components-json-file-found-ensure-you-are-at","errorCode":null,"errorMessage":"No `components.json` file found. Ensure you are at the root of your project.","messagePattern":"No `components\\.json` file found\\. Ensure you are at the root of your project\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/commands/migrate.ts","lineNumber":99,"sourceCode":"        for (const migration of migrations) {\n          logger.info(`- ${migration.name}: ${migration.description}`)\n        }\n        return\n      }\n\n      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      }","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/commands/migrate.ts#L81-L117","documentation":"preFlightMigrate reported MISSING_DIR_OR_EMPTY_PROJECT or MISSING_CONFIG — the cwd is empty or has no components.json. The migrate command needs an already-initialized shadcn project to operate on.","triggerScenarios":"Running `shadcn migrate <name>` from a directory without components.json, or from an empty/brand-new directory; preFlightMigrate could not locate or validate a project config.","commonSituations":"Wrong terminal cwd (home dir, subdirectory), fresh repo that was never initialized, components.json deleted or never committed, monorepo run from the wrong package.","solutions":["Run `shadcn init` first to create components.json.","cd to the project root that contains components.json.","Verify the file exists: `ls components.json`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import fs from \"fs\"\nimport path from \"path\"\n\nfunction assertHasComponentsJson(cwd: string) {\n  if (!fs.existsSync(path.resolve(cwd, \"components.json\"))) {\n    throw new Error(\"Run `shadcn init` before `shadcn migrate`.\")\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run migrate only after a successful shadcn init.","Confirm cwd is the project root before invoking."],"tags":["migrate","config","init"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}