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

$lib/components" does not use an existing path alias defined in your jsconfig.json #1474

Closed
ianengelbrecht opened this issue Nov 10, 2024 · 9 comments

Comments

@ianengelbrecht
Copy link

Describe the bug

I'm using a Svelte (not SvelteKit) project managed with Vite, no typescript. When I run npx shadcn-svelte@latest init I get a message $lib/components" does not use an existing path alias defined in your jsconfig.json.

jsconfig looks has this:

"paths": {
    "$components": ["src/components"],
    "$components/*": ["src/components/*"],  
    "$utils": ["src/utils"],
    "$utils/*": ["src/utils/*"] 
  }

vite.config has:

resolve: {
    alias: {
      $lib: path.resolve("./src/lib"),
      $components: path.resolve("./src/components")
    },
  }

Thanks!

The vite installation of Svelte only comes with $lib, I added $ components and $utils myself, perhaps init should update the config files for you?

Reproduction

https://github.com/ianengelbrecht/svelte-shadcn-time-picker

Clone, install, and try npx shadcn-svelte@latest init

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-1345U
    Memory: 17.81 GB / 31.66 GB
  Binaries:
    Node: 20.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.89)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    svelte: ^5.1.3 => 5.1.13

Severity

blocking all usage of shadcn-svelte

@ianengelbrecht
Copy link
Author

Confirmed that this does not occur with a project created with npm create vite@latest my-app -- --template svelte-ts

@ieedan
Copy link
Contributor

ieedan commented Nov 10, 2024

I opened a PR on your repo that fixes the config files. I don't believe we make any changes to jsconfig.json so maybe some documentation would help here?

@ieedan
Copy link
Contributor

ieedan commented Nov 10, 2024

Can you create a new repro without trying to update the config files yourself? In this case the config files were just incorrectly modified.

@ianengelbrecht
Copy link
Author

ianengelbrecht commented Nov 10, 2024 via email

@ieedan
Copy link
Contributor

ieedan commented Nov 10, 2024

Take another look its its adding an import and moving the options.

Please share the repro.

@Nokorbis
Copy link

I have the same issue with a project created with
Tauri (2.1.1)+ Svelte-kit ( (2.8.1) [svelte 5.2.0]

It was however fixed by running vite (or at least pnpm tauri dev, which I guess runs vite) AFTER adding an alias in svelte.config.js and BEFORE running the command pnpm dlx shadcn-svelte@next init

@huntabyte
Copy link
Owner

Oh yeah that initial step is responsible for building out the appropriate tsconfig.json / jsconfig.json @Nokorbis

@huntabyte
Copy link
Owner

If someone wants to add "run your dev server once" to the docs we can probably close this issue

ieedan added a commit to ieedan/shadcn-svelte that referenced this issue Nov 15, 2024
@AdrianGonz97
Copy link
Collaborator

fixed by #1487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants