shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
75.33k stars 4.72k forks source link

[bug]: Custom utils path inside `components.json` is being ignored #5544

Open dx1ded opened 1 month ago

dx1ded commented 1 month ago

Describe the bug

Here's my components.json file:

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "tailwind.config.ts",
    "css": "src/styles/globals.css",
    "baseColor": "gray",
    "cssVariables": true,
    "prefix": ""
  },
  "aliases": {
    "components": "~/shared/components",
    "utils": "~/shared/lib",
    "ui": "~/shared/ui-kit",
    "lib": "~/shared/lib",
    "hooks": "~/shared/hooks"
  }
}

However, when adding component cn is always being imported from ~/lib/utils even though I explicitly specified it from ~/shared/lib.

Affected component/components

Every

How to reproduce

  1. Modify your components.json to match mine.
  2. Try to add a component, for example npx shadcn@latest add sidebar

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Node@20.18.0, React@19.0.0-rc-69d4b800-20241021, NextJS@15.0.1

Before submitting

its-me-sv commented 1 month ago

I thought I was not configuring properly, seems like that isn't the case. Happy to know I'm not the only one 😂

Tobbe commented 4 weeks ago

I ran into this myself and wrote up a fix for it here https://github.com/shadcn-ui/ui/pull/5616

Tobbe commented 4 weeks ago

If anyone wants to try my fix I published it to my own npm registry

Just run npx -y https://verdaccio.tobbe.dev/shadcn/-/shadcn-2.1.2-tobbe-20241029-0244.tgz add button or whatever component you want to try with :)