unovue / shadcn-vue

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

[Bug]: NuxtJS installation process targets the wrong directory #806

Open long-win opened 2 weeks ago

long-win commented 2 weeks ago

Reproduction

After running npx shadcn-vue@latest init

Describe the bug

I ran the init command in the root directory of my Nuxt project and the component and utils folder were created in the folder one level above my project root directory.

I followed everything in the installation instruction, namely

  1. npx nuxi@latest init nuxt-shadcn-project
  2. cd ~/projects/nuxt-shadcn-project
  3. npm install -D typescript
  4. npx nuxi@latest module add @nuxtjs/tailwindcss
  5. npx nuxi@latest module add shadcn-nuxt
  6. Configure nuxt.config.ts `export default defineNuxtConfig({ modules: ['@nuxtjs/tailwindcss', 'shadcn-nuxt'], shadcn: { /**
    • Prefix for all the imported component */ prefix: '', /**
    • Directory that the component lives in.
    • @default "./components/ui" */ componentDir: './components/ui' } })`
  7. npx shadcn-vue@latest init
  8. Would you like to use TypeScript (recommended)? no / yes Which framework are you using? Nuxt Which style would you like to use? › Default Which color would you like to use as base color? › Slate Where is your tsconfig.json or jsconfig.json file? › ./tsconfig.json Where is your global CSS file? › › src/index.css Do you want to use CSS variables for colors? › no / yes Where is your tailwind.config.js located? › tailwind.config.js Configure the import alias for components: › @/components Configure the import alias for utils: › @/lib/utils Write configuration to components.json. Proceed? > Y/n

Let's say my project folder structure is as follows: What I expected projects |── nuxt-shadcn-project | |── components | |── lib | |── utils.ts

What it turns out to be projects |── nuxt-shadcn-project |── components |── lib |── utils.ts

I have double checked everything and rerun the whole thing at least 5 times, including nuxt.config.ts

System Info

System:
    OS: macOS 15.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 272.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.0 - /usr/local/bin/node
    npm: 10.2.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 129.0.6668.100
    Edge: 129.0.2792.89
    Safari: 18.0
  npmPackages:
    nuxt: ^3.13.0 => 3.13.2
    radix-vue: ^1.9.7 => 1.9.7
    shadcn-nuxt: ^0.10.4 => 0.10.4
    vue: latest => 3.5.12

Contributes

gavinhar commented 1 week ago

I've seen the same issue. Work around until this gets fixed is to copy things from ./components/ui and ./lib into .//components/ui and ./ into .//lib

ThePromiseBenard commented 1 week ago

This is same with me, i kept thinking I was doing something bad as well.

sadeghbarati commented 1 week ago

Maybe Related to https://github.com/unovue/shadcn-vue/issues/291

https://github.com/unovue/shadcn-vue/issues/291#issuecomment-1901788144