#Error on published app in docker container

42 messages · Page 1 of 1 (latest)

hazy estuary
#

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),

grand dirgeBOT
#

Hi @hazy estuary. 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 }
    })
    
    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
    }
    
    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.
#
  1. 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:

#

@hazy estuary Kapa.ai is still learning and improving, please let me know how I did by reacting below.

hazy estuary
#

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

coral lava
#

hi I can help you, please let me know the detailed error message

hazy estuary
# coral lava 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),

coral lava
#

ok let me find a solution to this issue

hazy estuary
#

thanks

coral lava
#

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

hazy estuary
#

thanks, I've already disabled dev tools

#

there is no logical explanation for this

coral lava
#

Umm

#

weird then

#

after disabling it, it's working fine?

hazy estuary
#

nope

coral lava
#

can you share the project so that I can have a look in detail?

hazy estuary
#

not it's company work

coral lava
#

Oh I see

hazy estuary
#

it's fine I'll figure it out

coral lava
#

ok

#

where are you based in?

hazy estuary
#

why does it matter?

coral lava
#

just out of curiosity

hazy estuary
#

ah, europe then

coral lava
#

If you don't want, it's okay

hazy estuary
#

hbu?

coral lava
#

about me?

#

italy

hazy estuary
#

nice

#

well I gotta do some work

coral lava
#

ok

#

good luck

hazy estuary
#

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

coral lava
#

Then it was node.js version problem?

#

compatibilty issue?

hazy estuary
#

yeah version issue

#

latest node did not like nuxt

coral lava
#

yeah