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
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,
You should explicitly disable DevTools in your Nuxt configuration for production. For example, in your
If you have previously built your project with devtools enabled, you may need to clean up your build artifacts. Delete
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
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 ProductionYou should explicitly disable DevTools in your Nuxt configuration for production. For example, in your
nuxt.config.ts:
Or, if you are using a module that has its own devtools option (like @nuxt/fonts), set its devtools option to false as well:
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 ArtifactsIf 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:
----------------------<@237189429159002112> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
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
hi I can help you, please let me know the detailed error message
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),
ok let me find a solution to this issue
thanks
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
thanks, I've already disabled dev tools
there is no logical explanation for this
Umm
weird then
after disabling it, it's working fine?
nope
can you share the project so that I can have a look in detail?
not it's company work
Oh I see
it's fine I'll figure it out
ok
where are you based in?
why does it matter?
just out of curiosity
ah, europe then
If you don't want, it's okay
hbu?
about me?
italy
nice
well I gotta do some work
ok
good luck
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
Then it was node.js version problem?
compatibilty issue?
yeah version issue
latest node did not like nuxt
yeah
really stressful sometimes.
Maybe it's more like Devops than coding