rob-balfre / svelte-select

Svelte Select. A select component for Svelte
https://svelte-select-examples.vercel.app
Other
1.27k stars 180 forks source link

Unknown file extension ".svelte" on svelte-kit #393

Closed Cluster2a closed 2 years ago

Cluster2a commented 2 years ago

Hey, I am using svelte-kit with tailwindcss.

I installed the beta version pnpm install svelte-select@beta because I wanted to try the no-styles-Components. When importing the compontent, I am getting the following error:

import Select from 'svelte-select/no-styles/Select.svelte'
Unknown file extension ".svelte" for /app/node_modules/.pnpm/svelte-select@5.0.0-beta.6/node_modules/svelte-select/no-styles/Select.svelte
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /app/node_modules/.pnpm/svelte-select@5.0.0-beta.6/node_modules/svelte-select/no-styles/Select.svelte
    at new NodeError (node:internal/errors:363:5)
    at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
    at Loader.getFormat (node:internal/modules/esm/loader:105:42)
    at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
    at async Loader.import (node:internal/modules/esm/loader:177:17)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async nodeImport (/app/node_modules/.pnpm/vite@2.9.1_sass@1.50.0/node_modules/vite/dist/node/chunks/dep-611778e0.js:58433:21)
    at async eval (/src/lib/Components/Planner/BookingModal.svelte:27:32)
    at async instantiateModule (/app/node_modules/.pnpm/vite@2.9.1_sass@1.50.0/node_modules/vite/dist/node/chunks/dep-611778e0.js:58364:9)

It's usually not a problem to import svelte-components in my app, this might be an issue with pnpm?

Edit: I checked with npm and it's working fine. I wasn't able to find any settings regarding to file extensions in pnpm.

rob-balfre commented 2 years ago

@Cluster2a which version of sveltekit are you on?

Cluster2a commented 2 years ago

@rob-balfre

Svelte-kit: 1.0.0-next.311 pnpm: 6.31.0

rob-balfre commented 2 years ago

@Cluster2a thanks.

I've just setup a new project using pnpm + kit + tailwind + svelte-select@beta and it all works fine. I'll create a demo repo and post it here. Then maybe we can debug and compare setups.

rob-balfre commented 2 years ago

@Cluster2a here you go: https://github.com/rob-balfre/svelte-select-examples/tree/main/kit-tailwind

Cluster2a commented 2 years ago

Okay - this is strange... I checked again on my project, and today it is working. Weird! Sorry for the circumstances, and thanks a lot!

gterras commented 1 year ago

For future readers I've just met this error on SvelteKit after installing v5.0.0-beta.40. Removing .svelte-kit folder and relaunching npm run dev made the error disappear.

happysalada commented 1 year ago

Adding svelte-select as a devDependency rather than a dependency will cause this error as well. Moving it to a regular dependency fixes this.