unovue / shadcn-vue

Vue port of shadcn-ui
https://www.shadcn-vue.com/
MIT License
5.06k stars 296 forks source link

[Bug]: Two component files resolving to the same name <component name> (Nuxt 4) #763

Closed onurusluca closed 1 month ago

onurusluca commented 1 month ago

Reproduction

Sorry, tried but can't get StackBlitz or CodeSandbox working.

Describe the bug

Even with TypeScript installed as a dependency, with Nuxt 4, getting this error. This was resolved before with Nuxt 3 versions by installing TypeScript.

Reproduction: I am sorry I wasn't able to add a reproduction. If someone can share, it'd be much appreciated. Use Nuxt 4, add Shadcn-vue, pnpm dev.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor     
    Memory: 9.54 GB / 31.93 GB
  Binaries:
    Node: 20.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.10.0 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (128.0.2739.42)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @vueuse/core: ^11.0.3 => 11.0.3
    nuxt: 3.13.1 => 3.13.1
    radix-vue: ^1.9.5 => 1.9.5
    shadcn-nuxt: ^0.10.4 => 0.10.4
    vue: ^3.5.4 => 3.5.5

Contributes

onurusluca commented 1 month ago

Of course just after 5 minutes of posting the question, I find the answer. :D

Fix:

  shadcn: {
    prefix: "",
    componentDir: "./app/components/ui",  // Change to new directory
  },

Change your componentDir to new components directory, It was componentDir: "./components/ui" before.

Just an FYI: I had to change some of my imports that are outside of the "app" folder because now @ or ~ not points to "app" not "/".

thiagolcks commented 3 weeks ago

Thank you @onurusluca ! I was facing the same problem, I didn't realized that @ do not work here.