Svelte instantiateModule error

Svelte instantiateModule error while importing component

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/

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 :)