huntabyte / shadcn-svelte

shadcn/ui, but for Svelte. ✨
https://shadcn-svelte.com
MIT License
4.95k stars 304 forks source link

`npx shadcn-svelte@latest init` does not recognise `$lib/components` as aliased in SvelteKit. #1073

Closed ezra-en closed 4 months ago

ezra-en commented 4 months ago

Describe the bug

npx shadcn-svelte@latest init does not recognise $lib/components as aliased in SvelteKit. Going through the init flow as instructed will result in this:

Screenshot 2024-05-05 at 11 02 27 PM

Reproduction

no repro. go through the SvelteKit install flow with cli v0.10.5.

Logs

No response

System Info

System:
    OS: macOS 14.4.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 2.01 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.18.0/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 9.0.6 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.119
    Safari: 17.4.1
  npmPackages:
    @sveltejs/kit: ^1.20.4 => 1.21.0 
    svelte: ^4.0.0 => 4.0.1

Severity

blocking all usage of shadcn-svelte

AdrianGonz97 commented 4 months ago

Was this executed in a new project or a preexisting one? Judging by the output of the system info, it looks like an older project.

If that's the case, can you send the contents of your svelte.config.js file and your tsconfig.json?

ezra-en commented 4 months ago

This was executed in a pre-existing SvelteKit project, yes.

`tsconfig.json`

```json { "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { "allowJs": true, "checkJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, "strict": true } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes // from the referenced tsconfig.json - TypeScript does not merge them in } ```

`svelte.config.js`

```javascript import adapter from '@sveltejs/adapter-static'; import { vitePreprocess } from '@sveltejs/kit/vite'; /** @type {import('@sveltejs/kit').Config} */ const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors // for more information about preprocessors preprocess: vitePreprocess(), kit: { adapter: adapter({ fallback: 'index.html' }) } }; export default config; ```

ezra-en commented 4 months ago

This is an older project template that I had and just used to pick up an old project I needed to work with. I can try and port everything over and reinit the project (it's no biggie) but since there was an issue with what is supposed to be a supported svelte-kit project, I thought I would open an issue.

AdrianGonz97 commented 4 months ago

Do you have a src/lib directory? IIRC, older versions of sveltekit won't generate the $lib path alias if the lib dir doesn't exist.

ezra-en commented 4 months ago

Hey, that's correct! I don't have that by default. Just adding the directory back manually got the init flow working again!