Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: shadcn-nuxt when the buildDir is changed an error is thrown ENOENT: no such file or directory, stat 'PROJECT_PATH/.nuxt/tsconfig.json' #429

Closed
2 tasks done
samk-dev opened this issue Mar 23, 2024 · 4 comments · Fixed by #447
Labels
bug Something isn't working

Comments

@samk-dev
Copy link
Contributor

samk-dev commented Mar 23, 2024

Reproduction

https://stackblitz.com/edit/github-gxjekn?file=nuxt.config.ts

Describe the bug

when changing the buildDir from nuxt.config.ts the cli throws an error when generating new components ENOENT: no such file or directory, stat 'PROJECT_PATH/.nuxt/tsconfig.json'.

Screenshot 2024-03-23 at 11 24 05

System Info

- Operating System: `Darwin`
- Node Version:     `v20.11.0`
- Nuxt Version:     `3.11.1`
- CLI Version:      `3.11.1`
- Nitro Version:    `2.9.4`
- Package Manager:  `npm@10.2.4`
- Builder:          `-`
- User Config:      `devtools`, `app`, `modules`, `shadcn`
- Runtime Modules:  `@nuxtjs/tailwindcss@6.11.4`, `shadcn-nuxt@0.10.2`
- Build Modules:    `-`

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@samk-dev samk-dev added the bug Something isn't working label Mar 23, 2024
@samk-dev
Copy link
Contributor Author

I have found the cause of the issue :)

In packages/cli/src/utils/get-config.ts on line 71 the buildDir is being accessed with static string.nuxt

let tsConfigPath = path.resolve(
    cwd,
    config.framework === 'nuxt' ? '.nuxt/tsconfig.json' : './tsconfig.json',
  )

I will check later if I have time to try to pass the buildDir from maybe components.json or nuxt.config as it's only affecting Nuxt?

Thanks

@zernonia
Copy link
Member

zernonia commented Apr 1, 2024

As Nuxt will generate a custom tsconfig.json in .nuxt folder, thus we are referencing that. Can you help check if .nuxt folder exist in your project? 😁

@samk-dev
Copy link
Contributor Author

samk-dev commented Apr 1, 2024

Hey @zernonia

When the buildDir is changed from nuxt.config the .nuxt dir changes it's name to that value here's the docs

export default defineNuxtConfig({
  buildDir: '.dist' // .nuxt dir will be renamed to .dist
})

in packages/cli/src/utils/get-config.ts the static .nuxt should be changed to pull a dynamic value from somewhere, it could be from components.json

const nuxtBuildDir = // we can get it from components.json if the option is added there
let tsConfigPath = path.resolve(
    cwd,
    // change this
    config.framework === 'nuxt' ? '.nuxt/tsconfig.json' : './tsconfig.json',
    // to something like this
    config.framework === 'nuxt' ? '${nuxtBuildDir}/tsconfig.json' : './tsconfig.json',
  )

sorry I couldn't do the contribution I am a little bit busy.

@samk-dev
Copy link
Contributor Author

samk-dev commented Apr 1, 2024

@zernonia I have submitted a pr to resolve this issue pr let me know if anything need to be modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants