I got the same error while migrating an app to SvelteKit. The FAQ states this is due to how Vite processes imports (even with SSR disabled). See "How do I use a client-side onlyβ¦" in SvelteKit FAQ as well as Issue #754 True SPA mode.
For now, I was able to get this working by disabling SSR on the page that depends on localStorageand importing & globally registering node-localstoragebefore importing the lib that depends on localStorage.
import 'node-localstorage/register';
import { storable } from 'svelte-storable';
The register endpoint in node-localstorage does not overwrite localStorage if it already exists, so you still get the native browser implementation.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I got the same error while migrating an app to SvelteKit. The FAQ states this is due to how Vite processes imports (even with SSR disabled). See "How do I use a client-side onlyβ¦" in SvelteKit FAQ as well as Issue #754 True SPA mode.
For now, I was able to get this working by disabling SSR on the page that depends on
localStorageand importing & globally registeringnode-localstoragebefore importing the lib that depends onlocalStorage.The
registerendpoint innode-localstoragedoes not overwritelocalStorageif it already exists, so you still get the native browser implementation.