nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
984 stars 56 forks source link

The deployment through an error 500 when we use pnpm as package manager #257

Closed lablnet closed 2 months ago

lablnet commented 2 months ago

Describe the bug The deployment through an error 500 when we use pnpm as package manager

Steps to reproduce Steps to reproduce the behavior:

  1. Create new NuxtJs project and install dependencies using pnpm
  2. Setup nuxtHub with cloudflare deployment
  3. Run npx nuxthub deploy to deploy
  4. Visit your site it will show 500 and in log something like this
    
    11:24:23.180
    Connected to production deployment logs...

11:24:23.629 GET 500 / [nuxt] [request error] [unhandled] [500],global is not defined at chunks/build/server.mjs:1:162051 [nuxt] [request error] [unhandled] [500],Cannot access 'default' before initialization at chunks/routes/renderer.mjs:1:114119
at async chunks/routes/renderer.mjs:1:114072
at async chunks/routes/renderer.mjs:1:116193
at async Object.handler (chunks/routes/renderer.mjs:1:115231)
at async Object.handler (chunks/runtime.mjs:1:74653)
at async chunks/runtime.mjs:1:77585
at async chunks/runtime.mjs:1:110187
at async errorHandler (chunks/runtime.mjs:1:105360)
at async chunks/runtime.mjs:1:77737
at async chunks/runtime.mjs:1:110187



6. If you remove `node_modules` folder and `pnpm-lock.yaml` then install package using either `yarn` or `npm` and redeploy it will works prefectly.

**Expected behavior**
- It should work with pnpm too!
atinux commented 2 months ago

All the NuxtHub templates are using pnpm actually. What is the project you are trying to deploy?

lablnet commented 2 months ago

All the NuxtHub templates are using pnpm actually. What is the project you are trying to deploy?

Simple nuxtjs app with one hello world server and coming soon page for fronted!

This is the repo you can easily reproduce the issue https://github.com/MacroHub-LCC/macrohub.net

atinux commented 2 months ago

Why do you have 2 times the modules key?
https://github.com/MacroHub-LCC/macrohub.net/blob/6847db9a63f46ef81a972dc299089b8c680f2989/nuxt.config.ts#L18-L27

lablnet commented 2 months ago

https://github.com/MacroHub-LCC/macrohub.net/blob/6847db9a63f46ef81a972dc299089b8c680f2989/nuxt.config.ts#L18-L27

It was typo, I removed it but still same error now even you can see https://macrohub.net/

atinux commented 2 months ago

Alright, you need to add a .npmrc when dealing with pnpm on your project (will check with the Nuxt team as it seems to be a regression somehow)

# .npmrc
shamefully-hoist=true

Then re-install the dependencies and deploy, it will work :)