[ERR_UNKNOWN_FILE_EXTENSION]
Closed this issue · 4 comments
vedam commented
I wanted to give svelte-knobby a try and got the following.
Unfortunately I don't know where this belongs to:
Is it vite, svelteKit, svelte-knobby or at least is it just me?
I made a clean svelteKit and svelte-knobby install and on pnpm run dev
:
8:22:51 AM [vite] Error when evaluating SSR module /src/routes/index.svelte:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /Users/acve/Documents/web/dev/knobby-test/node_modules/.pnpm/svelte-knobby@0.3.4_svelte@3.44.3/node_modules/svelte-knobby/Knobby.svelte
at new NodeError (node:internal/errors:371: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 ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:78:21)
at async Promise.all (index 0)
at async link (node:internal/modules/esm/module_job:83:9)
Unknown file extension ".svelte" for /Users/acve/Documents/web/dev/knobby-test/node_modules/.pnpm/svelte-knobby@0.3.4_svelte@3.44.3/node_modules/svelte-knobby/Knobby.svelte
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svelte" for /Users/acve/Documents/web/dev/knobby-test/node_modules/.pnpm/svelte-knobby@0.3.4_svelte@3.44.3/node_modules/svelte-knobby/Knobby.svelte
at new NodeError (node:internal/errors:371: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 ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:78:21)
at async Promise.all (index 0)
at async link (node:internal/modules/esm/module_job:83:9)
Edit:
Meanwhile I noticed that the page looks as expected if I reload the page after I started it.
I still get the error on starting it.
amr3k commented
Have you solved this issue?
vedam commented
Not really. I still get this error on a fresh start. After reloading the browser it's gone and everything's working.
vedam commented
Ok finally, thx to J on svelte-discord this change in svelte.config.js
seems a solution:
const config = {
...
vite: {
optimizeDeps: {
exclude: ['svelte-knobby']
},
ssr: {
noExternal: ['svelte-knobby']
}
}
...
};
I still don't know why I had to do this, but hey, it worked for me.