N
Nuxt2mo ago
Tiger

Error on published app in docker container

Hey, I get the below error, the site previosuly worked but I have no clue as to why dev tools would be loaded in production mode? I can't really pinpoint a source of the error. TypeError: localStorage.getItem is not a function at getTimelineLayersStateFromStorage (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2364:30) ... 8 lines matching cause stack trace ... at Module.require (node:internal/modules/cjs/loader:1502:12) { cause: TypeError: localStorage.getItem is not a function at getTimelineLayersStateFromStorage (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2364:30) at initStateFactory (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2657:26) at Object.<anonymous> (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2661:92) at Module._compile (node:internal/modules/cjs/loader:1759:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1479:32) at Module._load (node:internal/modules/cjs/loader:1298:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) at Module.require (node:internal/modules/cjs/loader:1502:12),
28 Replies
kapa.ai
kapa.ai2mo ago
Hi @khamas (ping me). I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're seeing, TypeError: localStorage.getItem is not a function, is happening because code that expects to run in a browser (where localStorage is available) is being executed on the server (Node.js), where localStorage does not exist. The stack trace points to @vue/devtools-kit being loaded in your production build, which should not happen. This issue is likely caused by Nuxt DevTools (or a related devtools integration) being enabled in your production environment. DevTools and related browser-only features should be disabled in production to avoid such errors. From the knowledge sources, there are two key points to address this: 1. Disable DevTools in Production
You should explicitly disable DevTools in your Nuxt configuration for production. For example, in your nuxt.config.ts:
export default defineNuxtConfig({
devtools: { enabled: false }
})

export default defineNuxtConfig({
devtools: { enabled: false }
})

Or, if you are using a module that has its own devtools option (like @nuxt/fonts), set its devtools option to false as well:
fonts: {
devtools: false
}

fonts: {
devtools: false
}

This has been confirmed as a solution for similar issues, especially on Windows, where having devtools enabled in production caused build/runtime errors. Deleting .output/server/node_modules and disabling devtools resolved the problem for affected users too many open files on build. 2. Clean Build Artifacts
If you have previously built your project with devtools enabled, you may need to clean up your build artifacts. Delete node_modules, .output, .nuxt, and lock files, then reinstall dependencies and rebuild your project. This ensures that no devtools code is accidentally included in your production build Cannot find module '@vue/shared' when running node .output/server/index.mjs after Nuxt 4 build. Summary:
DevTools should not be loaded in production. Make sure all devtools integrations are disabled in your production config, clean your build artifacts, and rebuild your project. This should resolve the error related to localStorage on the server. If you continue to see this error after these steps, double-check your modules and dependencies to ensure none of them are forcing devtools to be included in production. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@237189429159002112> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Tiger
TigerOP2mo ago
I get the error even when i disable dev tools when I run a local build and run it I don't get this error
dario
dario2mo ago
hi I can help you, please let me know the detailed error message
Tiger
TigerOP2mo ago
hey this is the only error message TypeError: localStorage.getItem is not a function at getTimelineLayersStateFromStorage (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2364:30) ... 8 lines matching cause stack trace ... at Module.require (node:internal/modules/cjs/loader:1502:12) { cause: TypeError: localStorage.getItem is not a function at getTimelineLayersStateFromStorage (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2364:30) at initStateFactory (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2657:26) at Object.<anonymous> (/site/build/server/node_modules/@vue/devtools-kit/dist/index.cjs:2661:92) at Module._compile (node:internal/modules/cjs/loader:1759:14) at Object..js (node:internal/modules/cjs/loader:1892:10) at Module.load (node:internal/modules/cjs/loader:1479:32) at Module._load (node:internal/modules/cjs/loader:1298:12) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) at Module.require (node:internal/modules/cjs/loader:1502:12),
dario
dario2mo ago
ok let me find a solution to this issue
Tiger
TigerOP2mo ago
thanks
dario
dario2mo ago
hey, Khamas, maybe the error happened because localStorage is being accessed in a server-side context. The error it’s coming from @vue/devtools-kit, which shouldn’t be loaded in production. Please try this devtools: { enabled: process.env.NODE_ENV === 'development' } in nuxt.config.ts
Tiger
TigerOP2mo ago
thanks, I've already disabled dev tools there is no logical explanation for this
dario
dario2mo ago
Umm weird then after disabling it, it's working fine?
Tiger
TigerOP2mo ago
nope
dario
dario2mo ago
can you share the project so that I can have a look in detail?
Tiger
TigerOP2mo ago
not it's company work
dario
dario2mo ago
Oh I see
Tiger
TigerOP2mo ago
it's fine I'll figure it out
dario
dario2mo ago
ok where are you based in?
Tiger
TigerOP2mo ago
why does it matter?
dario
dario2mo ago
just out of curiosity
Tiger
TigerOP2mo ago
ah, europe then
dario
dario2mo ago
If you don't want, it's okay
Tiger
TigerOP2mo ago
hbu?
dario
dario2mo ago
about me? italy
Tiger
TigerOP2mo ago
nice well I gotta do some work
dario
dario2mo ago
ok good luck
Tiger
TigerOP2mo ago
if anybody else can help me figure this stuff out 🙏 FOR FUTURE REFERENCE My docker image was using the latest nodejs, I downgraded to version 22 explicitly and it worked again
dario
dario2mo ago
Then it was node.js version problem? compatibilty issue?
Tiger
TigerOP2mo ago
yeah version issue latest node did not like nuxt
dario
dario2mo ago
yeah really stressful sometimes. Maybe it's more like Devops than coding

Did you find this page helpful?