ui icon indicating copy to clipboard operation
ui copied to clipboard

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

Open vovados1 opened this issue 1 year ago • 6 comments

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

[email protected], [email protected], [email protected]

Before submitting

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

vovados1 avatar Oct 24 '24 04:10 vovados1

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

its-me-sv avatar Oct 24 '24 05:10 its-me-sv

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

Tobbe avatar Oct 28 '24 22:10 Tobbe

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 :)

Tobbe avatar Oct 29 '24 02:10 Tobbe

This is still not working

mattzque avatar Sep 12 '25 12:09 mattzque

Same here. components.json is being ignored.

goldcaddy77 avatar Nov 05 '25 02:11 goldcaddy77

Also broken for me.

FranjoMindek avatar Nov 13 '25 10:11 FranjoMindek