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

ReferenceError: localStorage is not defined #635

Closed
Dennis4720 opened this issue Oct 16, 2024 · 7 comments
Closed

ReferenceError: localStorage is not defined #635

Dennis4720 opened this issue Oct 16, 2024 · 7 comments

Comments

@Dennis4720
Copy link

Dennis4720 commented Oct 16, 2024

Newest version.
"vite-plugin-vue-devtools": "^7.4.6",

npm run dev

> [email protected] dev
> vite --host 0.0.0.0

failed to load config from /Users/dennis/Projects/nq-client/vite.config.js
error when starting dev server:
ReferenceError: localStorage is not defined
    at getTimelineLayersStateFromStorage (file:///Users/dennis/Projects/nq-client/node_modules/@vue/devtools-kit/dist/index.js:2266:17)
    at initStateFactory (file:///Users/dennis/Projects/nq-client/node_modules/@vue/devtools-kit/dist/index.js:2546:26)
    at file:///Users/dennis/Projects/nq-client/node_modules/@vue/devtools-kit/dist/index.js:2550:68
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
    at async loadConfigFromBundledFile (file:///Users/dennis/Projects/nq-client/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:66680:15)
    at async loadConfigFromFile (file:///Users/dennis/Projects/nq-client/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:66521:24)
    at async resolveConfig (file:///Users/dennis/Projects/nq-client/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:66129:24)
    at async _createServer (file:///Users/dennis/Projects/nq-client/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:62747:18)
    at async CAC.<anonymous> (file:///Users/dennis/Projects/nq-client/node_modules/vite/dist/node/cli.js:735:20)
@webfansplz
Copy link
Member

I've try to fix it in v7.5.2. But I am so curious why this error occurs in the browser environment, can you try to provide minimal repo or share more info? thank you

@EDM115
Copy link

EDM115 commented Oct 16, 2024

getting the same issue on vite build :

> [email protected] build
> vite build

failed to load config from /home/runner/work/website/website/vite.config.js
error during build:
ReferenceError: localStorage is not defined
    at getTimelineLayersStateFromStorage (file:///home/runner/work/website/website/node_modules/@vue/devtools-kit/dist/index.js:22[6](https://github.com/EDM115/website/actions/runs/11366951788/job/31618497963?pr=150#step:5:7)6:17)
    at initStateFactory (file:///home/runner/work/website/website/node_modules/@vue/devtools-kit/dist/index.js:2546:26)
    at file:///home/runner/work/website/website/node_modules/@vue/devtools-kit/dist/index.js:2550:6[8](https://github.com/EDM115/website/actions/runs/11366951788/job/31618497963?pr=150#step:5:9)
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:483:26)
    at async loadConfigFromBundledFile (file:///home/runner/work/website/website/node_modules/vite/dist/node/chunks/dep-Cyk[9](https://github.com/EDM115/website/actions/runs/11366951788/job/31618497963?pr=150#step:5:10)bIUq.js:66680:15)
    at async loadConfigFromFile (file:///home/runner/work/website/website/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:66521:24)
    at async resolveConfig (file:///home/runner/work/website/website/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:66[12](https://github.com/EDM115/website/actions/runs/11366951788/job/31618497963?pr=150#step:5:13)9:24)
    at async build (file:///home/runner/work/website/website/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:65226:18)
    at async CAC.<anonymous> (file:///home/runner/work/website/website/node_modules/vite/dist/node/cli.js:828:5)
Error: Process completed with exit code 1.

edit: my bad, works on 7.5.2

@Dennis4720
Copy link
Author

But I am so curious why this error occurs in the browser environment, can you try to provide minimal repo or share more info? thank you

Thanks for your quick reply!

This happens in the console and prevents my local dev environment to boot. :) Anything else you want or need to know?

@Dennis4720
Copy link
Author

Can confirm it's been fixed. Cheers!

@playable-dannie
Copy link

@webfansplz Can we re-open this issue? The newly added undefined check doesn't work for WebViews who have localStorage disabled. When localStorage is disabled, then the value of localStorage is null, not undefined.

This breaks any application using vee-validate npm package since devtools for some reason is always embedded in the production build.

Or do i need to open a new issue?

@webfansplz
Copy link
Member

@webfansplz Can we re-open this issue? The newly added undefined check doesn't work for WebViews who have localStorage disabled. When localStorage is disabled, then the value of localStorage is null, not undefined.

This breaks any application using vee-validate npm package since devtools for some reason is always embedded in the production build.

Or do i need to open a new issue?

Thanks for the feedback, try to fix it in the v7.5.4 (vite plugin) and browser extension v7.0.0-beta.12 (pending review). Try it again.

@playable-dannie
Copy link

@webfansplz Wow you're fast 🚄 ! Faster than our review and QA pipeline for getting a rollback out.

I've updated the latest version and can confirm that it not works when WebViews on Android has their localStorage disabled. Awesome!

Virtual highfive from me 👍

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

4 participants