ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: Init creates `@` folder instead of alias for /components and /lib/utils.ts

Open T04435 opened this issue 3 months ago • 8 comments

Describe the bug

When using the init command leaving everything with defaults the output of the aliases is a folder @/components/ui @/lib/utils.ts

Instead we should get ~/components/ui ~/lib/utils.ts

Think the issue here: https://github.com/shadcn-ui/ui/blob/7590fb76364c46b72653623b6ee4a96f0ad0bca8/packages/cli/src/commands/init.ts#L327

when @/components/ui and @/lib are provided it creates the @/ folder.

Affected component/components

ALL

How to reproduce

  1. pnpm dlx shadcn-ui@latest init
  2. All defaults
  3. Created folders @/components/ui & @lib/utils
Screenshot 2024-04-07 at 11 52 30 PM Screenshot 2024-04-07 at 11 52 48 PM Screenshot 2024-04-07 at 11 55 57 PM

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

macOS: Sonoma 14.4.1 (23E224)

Before submitting

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

T04435 avatar Apr 07 '24 14:04 T04435

same happens if the path provided is ~/components/ui it creates a folder ~/ Screenshot 2024-04-08 at 12 13 42 AM

T04435 avatar Apr 07 '24 14:04 T04435

I too encountered the same problem. it took me a lot of time.

Did you find a solution?

randriamanampisoastone avatar Apr 07 '24 15:04 randriamanampisoastone

+1

ceednee avatar Apr 07 '24 15:04 ceednee

@T04435 could you share your tsconfig.json file?

servesh-chaturvedi avatar Apr 09 '24 04:04 servesh-chaturvedi

+1000 Here. Im using in a monorepo and having it create these folders on init is really messing with our config. It would also be great if i could separate the install folder from the import alias.

kmccrory-grx avatar Apr 16 '24 21:04 kmccrory-grx

I think I might be onto something. I fixed the issue for my situation so hopefully this info helps. I am using a turborepo monorepo, trying to generate shaycn-ui components in a packages/ui project. The issue seems to be with how typescript configurations operate against a baseUrl property.

I was extending packages/configs/typescript/base.json in my packages/ui/tsconfig.json. The configuration was added as a dependency in my project @repo/configs. I was hoping to inherit the setting for "baseUrl": "." that way, but Typescript saw this and used the relative path according to where the template file was located, at least I think so.

The result was a @repo/configs folder getting generated containing the shaycn-ui output, much like you guys reported but with an @ folder being made instead.

To fix it, I took the "baseUrl" property out of my base configuration template and moved it to my project. Upon running npx shadcn-ui@latest init it correctly generated the files in my src folder.

elijahmontenegro avatar May 08 '24 02:05 elijahmontenegro