Skip to content

[bug]: CLI addition of sidebar not supported in monorepo #6980

@PaulSinghDev

Description

@PaulSinghDev

Describe the bug

I have setup a monorepo with shadcn and it has been working great so far. The one issue I have found is that the <Sidebar /> component cannot be added via the CLI when in a monorepo.

When I run, for example npx shadcn@latest add alert everything is fine:

Image

However, when I run npx shadcn@latest add sidebar I get an error related to incorrect path resolution from the mappings of the folders in the workspace:

Image

This is the contents of the components.json file in the packages/ui directory:

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "@repo/tailwind-config/tailwind.config.ts",
    "css": "@repo/tailwind-config/globals.css",
    "baseColor": "neutral",
    "cssVariables": true
  },
  "iconLibrary": "lucide",
  "aliases": {
    "components": "@repo/ui/components",
    "utils": "@repo/ui/lib/utils",
    "hooks": "@repo/ui/hooks",
    "lib": "@repo/ui/lib",
    "ui": "@repo/ui/components"
  }
}

And this is the components.json of the apps/web directory:

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "default",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "@repo/tailwind-config/tailwind.config.ts",
    "css": "app/globals.css",
    "baseColor": "slate",
    "cssVariables": true,
    "prefix": ""
  },
  "aliases": {
    "components": "~/components",
    "utils": "@repo/ui/lib/utils",
    "ui": "@repo/ui/components",
    "lib": "~/lib",
    "hooks": "~/hooks"
  },
  "iconLibrary": "lucide"
}

Affected component/components

sidebar

How to reproduce

  1. Setup a monorepo
  2. cd into the web app
  3. run npx shadcn@latest add sidebar

Codesandbox/StackBlitz link

No response

Logs

System Info

System is macOS 14.6.1 (23G93)
Node v20.12.2

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