sidebase / nuxt-session

Nuxt session middleware to get a persistent session per app user, e.g., to store data across multiple requests. The nuxt session module provides the useSession() composable out of the box and sets up API endpoints to interact with your session to make working with sessions feel like a breeze.
https://sidebase.io/nuxt-session/
MIT License
189 stars 19 forks source link

Nuxt Fatal Error #56

Closed Noflare closed 1 year ago

Noflare commented 1 year ago

Environment

No response

Reproduction

No response

Describe the bug

When i install Nuxt-Session i have an error

Additional context

No response

Logs

FATAL  Cannot read properties of undefined (reading 'session')                                                                                                                                                           13:41:52  

  at setup (/C:/Users/Noflare/Desktop/EconomYx/app.economyx.fr/economyxdashboard/node_modules/@sidebase/nuxt-session/dist/module.mjs:51:74)
  at ModuleContainer.normalizedModule (/C:/Users/Noflare/Desktop/EconomYx/app.economyx.fr/economyxdashboard/node_modules/@nuxt/kit/dist/index.mjs:167:29)
  at async ModuleContainer.addModule (node_modules\@nuxt\core\dist\core.js:239:20)
  at async ModuleContainer.ready (node_modules\@nuxt\core\dist\core.js:55:5)
  at async Nuxt._init (node_modules\@nuxt\core\dist\core.js:478:5)

   ╭────────────────────────────────────────────────────────────────────────╮
   │                                                                        │
   │   ✖ Nuxt Fatal Error                                                   │
   │                                                                        │
   │   TypeError: Cannot read properties of undefined (reading 'session')   │
   │                                                                        │
   ╰────────────────────────────────────────────────────────────────────────╯

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
BracketJohn commented 1 year ago

Hey @Noflare 👋

Thanks for the issue.

Right now this looks like a different problem to me: Your error message says "trying to access property session of undefined@ -> this means that "event.context" is undefined and not (necessarily) "event.context.session".

So it rather seems to be a setup problem with your Nuxt 3 setup OR a problem with where you're accessing the "event.context".

Please look into this, and if you fix that and then "session" itself is undefined we can look into the problem here.

Please just comment here then and we'll reopen + investigate together. At that point it'd also be helpful to get a reproduction and more information about your environment!