ReferenceError: window is not defined

findingorder
0
findingorder
commented 6 months ago

When I try to clone and 'npm run dev' this project, it seems to build and launch just fine. But when I navigate to localhost:3000, I get the error "ReferenceError: window is not defined". The offending line of code is server-bundle.js line 3538, "const json = window.localStorage.user;". Call stack is:

server-bundle.js:3538:16 getUserFromLocalStorage
server-bundle.js:2341:185
server-bundle.js:1630:15 promisify
server-bundle.js:1609:10 middlewareSeries
server-bundle.js:1125:72

0
Syafiqq
0
Syafiqq
commented 2 days ago

add mode:spa will fix the problem

nuxt.config.js

module.exports = {
  mode: 'spa',
    ...
}
0
Informations
Question โ€ข Unresolved
#c28 - Created 6 months ago