Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"localSotrage is not defined" #2678

Closed
TomS- opened this issue Oct 25, 2021 · 1 comment
Closed

"localSotrage is not defined" #2678

TomS- opened this issue Oct 25, 2021 · 1 comment

Comments

@TomS-
Copy link

TomS- commented Oct 25, 2021

Describe the bug

When using adapater-static and ssr: false I'm getting the following error when running npm run build.

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-static
> localStorage is not defined
ReferenceError: localStorage is not defined
    at file:///www/wwwroot/domain-name.here/.svelte-kit/output/server/app.js:1751:45

This to me doesn't make sense as adapter-static from my knowledge isn't meant to be a node server. So it doesn't matter that localStorage is not defined server side as it's never intended to run server side. Refusing to build because of this just adds so much unnecessary complexity to a project as we have to build it as through it's running a NodeJS server with the knowledge that it will never.

Reproduction

  1. Create a project that uses localStorage in ssr: false mode. You will not see any errors it knows to run without server side rendering.
  2. Use the adapter-static to make it a static website.

You'll get the error that you can not use localStorage.

Logs

No response

System Info

System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (2) x64 DO-Premium-Intel
    Memory: 880.09 MB / 3.84 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.6 - /www/server/nvm/versions/node/v14.17.6/bin/node
    npm: 6.14.15 - /www/server/nvm/versions/node/v14.17.6/bin/npm
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.21 => 1.0.0-next.21 
    @sveltejs/kit: ^1.0.0-next.189 => 1.0.0-next.189 
    svelte: ^3.42.6 => 3.44.0

Severity

annoyance

Additional Information

No response

@dummdidumm
Copy link
Member

Duplicate of #1650 , this will likely be fixed by #2529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants