Skip to content

[bug]: Shadcn init does not work with the default installation of next.js with pnpm #9178

@SensoryDavide

Description

@SensoryDavide

Describe the bug

When using the default command to start a new next.js project via pnpm it adds a pnpm-workspace.yaml file with a single packages entry (It seems like the main purpose of it is to add ignoredBuiltDependencies):

packages:
  - .
ignoredBuiltDependencies:
  - sharp
  - unrs-resolver

This results in an error when running shadcn init:

Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.

Command failed with exit code 1: pnpm add clsx tailwind-merge class-variance-authority lucide-react

\u2009ERR_PNPM_ADDING_TO_ROOT\u2009 Running this command will add the dependency to the workspace root, which might not be what you want - if you really meant it, make it explicit by running this command again with the -w flag (or --workspace-root). If you don't want to see this warning anymore, you may set the ignore-workspace-root-check setting to true.

It seems like shadcn does not detect it's technically in the root of a workspaces project and pnpm doesn't allow to implicitly install anything in the root.

I've labeled this as a bug, as I think just adding shadcn to the default next.js installation should not result in an error.

Affected component/components

init

How to reproduce

  1. pnpm create next-app@latest my-app --yes
  2. cd my-app
  3. pnpm dlx shadcn@latest init

Codesandbox/StackBlitz link

No response

Logs

System Info

Not relevant

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions