JAGDEEP BISHT
JAGDEEP BISHT's Blog

JAGDEEP BISHT's Blog

Svelte instantiateModule error while importing component

Photo by David Pupaza on Unsplash

Svelte instantiateModule error while importing component

JAGDEEP BISHT's photo
JAGDEEP BISHT
·May 5, 2022·

1 min read

If you are new to Svelte, its very likely that you might run into the following error:

Error: failed to load module for ssr: /src/lib/song/SongMeta
    at instantiateModule (/home/jsbisht/workspace/github/jsbisht/rhythm-guitar-svelte/node_modules/vite/dist/node/
chunks/dep-e1fc1d62.js:59313:15)

The only change needed to fix this error is to specify the svelte file extension while importing a component.

So, instead of importing without extension:

import Panel from '$lib/Panel'

You must pass the extension while importing components:

import Panel from '$lib/Panel.svelte'

Hope this helped. Like, share and comment :)

 
Share this