core icon indicating copy to clipboard operation
core copied to clipboard

Production fails with new setup.

Open howardah opened this issue 1 year ago • 8 comments

Describe the bug A new setup with any vue components in the pages directory fails when run on nuxthub (seems to be an issue related to the release of vue 3.5) with the following error:

GET 500 /
[nuxt] [request error] [unhandled] [500],global is not defined
  at chunks/build/server.mjs:1:162352
[nuxt] [request error] [unhandled] [500],Cannot access 'default' before initialization
  at chunks/routes/renderer.mjs:1:119662  
  at async chunks/routes/renderer.mjs:1:119615  
  at async chunks/routes/renderer.mjs:1:121753  
  at async Object.handler (chunks/routes/renderer.mjs:1:120774)  
  at async Object.handler (chunks/runtime.mjs:1:72242)  
  at async chunks/runtime.mjs:1:75379  
  at async chunks/runtime.mjs:1:107021  
  at async errorHandler (chunks/runtime.mjs:1:102964)  
  at async chunks/runtime.mjs:1:75531  
  at async chunks/runtime.mjs:1:107021

Steps to reproduce

  1. Setup a new nuxt project with npx nuxi init
  2. Replace the <NuxtWelcome /> component with a <NuxtPage /> component in the app.vue file.
  3. Add an index.vue file in the pages/ directory with any content.
  4. Push to github repo.
  5. Deploy on NuxtHub using the admin panel at admin.hub.nuxt.com by linking to github repo.
  6. Attempt to visit the deployed site and check the production logs.

Expected behavior No error should be thrown

ps - Error is present regardless of whether the NuxtHub module is present, so this is likely an error on the nitro side of things (?) but since it's related to NuxtHub, I figured it made sense to post it here. But please let me know if I should remove the issue and recreate it on the nitro repo instead!

pps - here is a reproduction repo: https://github.com/howardah/nuxthub-error-reproduction which is deployed here: nuxthub-error-reproduction.nuxt.dev

howardah avatar Sep 05 '24 08:09 howardah

We need to update our templates since the latest version of Nuxt.

Could you please install vue-router as dependency?

pnpm add vue-router

And confirm it works?

atinux avatar Sep 05 '24 09:09 atinux

@atinux, sorry for the slow reply here, I've been away from it all day. I can confirm that adding vue-router as a dependency resolves the error!

howardah avatar Sep 05 '24 18:09 howardah

Ran into the same issue trying to deploy my project (running Nuxt 3.13.0), adding the vue-router dep fixed it for me as well!

Nuxthub is looking great, can't wait to move all my projects from Vercel to the hub 🔥

GreenmeisterDavid avatar Sep 06 '24 09:09 GreenmeisterDavid

Cannot get it to work with vue-router. I am using npm instead of pnpm. npm install vue-router. Do I miss anything?

"dependencies": {
    "@nuxt/eslint": "^0.5.6",
    "@nuxthub/core": "^0.7.10",
    "nuxt": "^3.13.0",
    "vue-router": "^4.4.3"
  },

fabianwohlfart avatar Sep 09 '24 09:09 fabianwohlfart

Try to install vue-router and vue as well @fabianwohlfart

Related Nuxt PR: https://github.com/nuxt/nuxt/pull/28846


Another solution is to have a .npmrc:

# .npmrc
shamefully-hoist=true

And install the dependencies again.

atinux avatar Sep 11 '24 10:09 atinux

~~Works, thanks.~~ (edited) Does not work. I think I stay with patch-package for now…

Would I need to do this workaround with the next Nuxt patch 3.13.2?

fabianwohlfart avatar Sep 11 '24 20:09 fabianwohlfart

Could you please try now with Nuxt 3.13.2?

atinux avatar Sep 16 '24 13:09 atinux

Could you please try now with Nuxt 3.13.2?

It's in production now and i have no staging set up, so I would need a proper timeframe to test it again. Maybe within the next two weeks. Sorry that I cannot be quicker with this.

fabianwohlfart avatar Sep 17 '24 15:09 fabianwohlfart