vuejs / devtools

⚙️ Browser devtools extension for debugging Vue.js applications.
https://devtools.vuejs.org/
MIT License
1.7k stars 122 forks source link

ReferenceError: localStorage is not defined #635

Closed Dennis4720 closed 4 weeks ago

Dennis4720 commented 1 month ago

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

npm run dev

> nq-client@0.0.0 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 commented 1 month ago

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 commented 1 month ago

getting the same issue on vite build :

> edm115-website@0.3.1 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 commented 1 month ago

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 commented 1 month ago

Can confirm it's been fixed. Cheers!

playable-dannie commented 4 weeks ago

@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 commented 4 weeks ago

@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 commented 4 weeks ago

@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 👍