ReferenceError: window is not defined
See original GitHub issueDescribe the bug
After some time (from 1.0.0-next.87
) I am using SvelteKit again.
With 87 I can use console.log(window.localStorage)
in $layout.svelte
.
If I use the same code now (with 108) it throws with:
ReferenceError: window is not defined
at __layout.svelte:5:43
NOTE: the default SvelteKit init demo comes without adapters, should I add one? Is this the issue?
To Reproduce
- npm init svelte@next my-app
- cd my-app
- npm install
- add
console.log(window.localStorage)
to__layout.svelte
right before</script>
- npm run dev
Expected behavior It prints in console.
Information about your SvelteKit Installation:
Diagnostics
-
The output of
npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
:System: OS: Windows 10 10.0.19042 Binaries: Node: 14.17.0 - C:\Program Files\nodejs\node.EXE npm: 7.13.0 - C:\Program Files\nodejs\npm.CMD npmPackages: @sveltejs/kit: 1.0.0-next.108 => 1.0.0-next.108 svelte: 3.38.2 => 3.38.2 vite: 2.3.3 => 2.3.3
-
Your browser: Chrome 90
-
Your adapter: none
Severity I cannot work.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
See https://github.com/sveltejs/kit/discussions/3365#discussioncomment-1976132
Re: gustavneustadt comment above for people finding this issue in the future
comment on https://github.com/sveltejs/kit/issues/4849 by mrkishi:
see also: