nuxt-hub / core

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

`ERROR: Cannot read properties of undefined (reading 'options')` when setting up external Nuxt project with NuxtHub #285

Closed Remi-Toussaint closed 2 months ago

Remi-Toussaint commented 2 months ago

Describe the bug When setting up an external Nuxt project with NuxtHub as a remote backend, following the documentation, running npx nuxi prepare results in the error:

Cannot read properties of undefined (reading 'options')
  at Object.normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:2202:12)
  at eval (node_modules/@nuxthub/core/dist/module.cjs#cjs:2:59)
  at async resolveConfig (node_modules/c12/dist/shared/c12.cab0c9da.mjs:368:18)
  at async extendConfig (node_modules/c12/dist/shared/c12.cab0c9da.mjs:275:21)
  at async Module.loadConfig (node_modules/c12/dist/shared/c12.cab0c9da.mjs:207:5)
  at async Module.loadNuxtConfig (node_modules/@nuxt/kit/dist/index.mjs:2683:18)
  at async loadNuxt (node_modules/nuxt/dist/index.mjs:4608:19)
  at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2750:19)
  at async Object.run (node_modules/nuxi/dist/chunks/prepare.mjs:76:18)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.fefc5017.mjs:1680:16)

Steps to reproduce Create a fresh Nuxt project. Install @nuxthub/core (npm install @nuxthub/core). Update nuxt.config.ts:

export default defineNuxtConfig({
  extends: ['@nuxthub/core'],
  hub: {
    remote: true
  }
})

Add .env variables:

NUXT_HUB_PROJECT_URL=https://my-nuxthub-project.pages.dev
NUXT_HUB_PROJECT_SECRET_KEY=my-project-secret

Run npx nuxi prepare. Error: Cannot read properties of undefined (reading 'options').

Minimal reproduction https://stackblitz.com/edit/github-2psy6y-x8fxvc?file=nuxt.config.ts

atinux commented 2 months ago

I don't know where you see the extends: ['@nuxthub/core'] but it is a module:

export default defineNuxtConfig({
  // extends: ['@nuxthub/core'] <-- this is wrong
  modules: ['@nuxthub/core']
})
Remi-Toussaint commented 2 months ago

Well, the doc actually says to "Add it to the extends section in your nuxt.config and set the remote option to true." You can check it out here: https://hub.nuxt.com/docs/getting-started/remote-storage#external-nuxt-projects

atinux commented 2 months ago

Damn, very sorry about this 🤦‍♂️

Fixed in https://github.com/nuxt-hub/core/commit/9f4a5f08be5915d15e468979780664f844be121c

Thank you for reporting 💚