> ## Documentation index
> Fetch the complete documentation index at: https://create-shadcn-js.docs.hyperdyn.in/llms.txt
> Ask it with GET https://create-shadcn-js.docs.hyperdyn.in/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Troubleshooting

> Fix the most common scaffold, dependency, and shadcn init failures.

## `components.json is missing or invalid`

The shadcn init step did not finish. This is usually a network, registry, or CLI failure.

```bash
# Tailwind v4 project
npx shadcn@4 init
```

```bash
# Tailwind v3 project
npx shadcn@2.3.0 init
```

Then re-run the component command. `create-shadcn-js` exits non-zero when this validation fails, so a failed scaffold is not reported as successful.

## `index.css is missing theme variables`

The shadcn init stopped before writing the theme. Re-run the CLI, or finish the init inside the project:

```bash
npx shadcn@4 init
```

For v3 projects, confirm `tailwind.config.js` and `src/index.css` still exist. The v3 scaffold owns the HSL theme because the legacy CLI writes v4-flavored variables.

## `package.json is missing ...`

The shadcn init did not install its declared dependencies. Check the package manager output and network access, then run:

```bash
npx shadcn@4 init
```

For v3:

```bash
npx shadcn@2.3.0 init
```

## A starter component could not be added

The scaffold still completes and `src/App.jsx` remains valid. Add the component later with the command printed in the warning:

```bash
npx shadcn@4 add button
```

## `Target directory "." is not empty`

Non-interactive mode (`-y`) never deletes existing files without permission. Choose a new project name, or intentionally overwrite:

```bash
npx create-shadcn-js@latest my-app -y --force
```

Only use `--force` on a directory you own and intend to replace.

## `Refusing to scaffold into ... Choose a project subdirectory instead.`

The CLI blocks scaffolding directly into its own package directory or a protected target. Pass a project name:

```bash
npx create-shadcn-js@latest my-app
```

## Invalid project name

Names may contain letters, numbers, hyphens, underscores, dots, and `@`. Path separators, `..`, leading hyphens, trailing dots, and Windows reserved names are rejected.

```bash
# Valid
npx create-shadcn-js@latest my-app

# Invalid
npx create-shadcn-js@latest ../my-app
```

## `yarn dlx` is unavailable

Yarn 1 does not support `dlx`. The CLI automatically falls back to `npx`. Newer Yarn Berry releases use `yarn dlx`.

## Node version errors

Use Node.js `^20.19.0` or `>=22.12.0`:

```bash
node --version
```

Upgrade Node, then re-run the scaffold in a fresh directory.

## Imports cannot resolve `@/...`

Check that all three alias declarations agree:

- `jsconfig.json` has `baseUrl` and `@/*` paths.
- `vite.config.js` resolves `@` to `./src`.
- `components.json` uses the `@/components` and `@/lib/utils` aliases.

For a broken project, run shadcn init again inside it and inspect `components.json` before adding more components.

## shadcn add uses the wrong CLI version

Match the CLI to the Tailwind path:

| Tailwind | Command |
| --- | --- |
| v4 | `npx shadcn@4 add <component>` |
| v3 | `npx shadcn@2.3.0 add <component>` |

Using the v4 CLI on a v3 project can rewrite the theme and break the build.

## Still stuck?

Open an issue with the command, Node version, package manager, Tailwind version, and the full error output:

<https://github.com/Skandan-V/create-shadcn-js/issues>
