shadcn-ui/ui · error

No `components.json` file found. Ensure you are at the root

Error message

No `components.json` file found. Ensure you are at the root of your project.

What it means

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.

Source

Thrown at packages/shadcn/src/commands/migrate.ts:99

        for (const migration of migrations) {
          logger.info(`- ${migration.name}: ${migration.description}`)
        }
        return
      }

      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,
        })
      }

View on GitHub (pinned to efac598707)

Solutions

  1. Run `shadcn init` first to create components.json.
  2. cd to the project root that contains components.json.
  3. Verify the file exists: `ls components.json`.
Defensive patterns

Strategy: validation

Validate before calling

import fs from "fs"
import path from "path"

function assertHasComponentsJson(cwd: string) {
  if (!fs.existsSync(path.resolve(cwd, "components.json"))) {
    throw new Error("Run `shadcn init` before `shadcn migrate`.")
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: Wrong terminal cwd (home dir, subdirectory), fresh repo that was never initialized, components.json deleted or never committed, monorepo run from the wrong package.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/e323b388f76ac15a. Report an issue: GitHub.