nuxt / bridge

🌉 Experience Nuxt 3 features on existing Nuxt 2 projects
MIT License
273 stars 29 forks source link

Cannot start nuxt: Cannot read properties of undefined (reading 'hook') #849

Closed rmj-s closed 1 year ago

rmj-s commented 1 year ago

Environment


------------------------------
- Operating System: Windows_NT
- Node Version:     v18.16.1
- Nuxt Version:     2.17.0
- Nitro Version:    2.5.2
- Package Manager:  npm@9.5.1
- Builder:          webpack
- User Config:      head, css, plugins, components, buildModules, modules, build, router, bootstrapVue, toast, sweetalert, loading, gtm, socialLogins
- Runtime Modules:  bootstrap-vue/nuxt, @nuxtjs/axios@5.13.6, @nuxtjs/pwa@3.3.5, @nuxtjs/toast@3.3.1, @nuxtjs/gtm@2.4.0, cookie-universal-nuxt@2.2.2, vue-sweetalert2/nuxt, @soufleco/nuxt-social-logins@1.1.0, ~logic
- Build Modules:    @nuxtjs/eslint-module@3.1.0, @nuxtclub/feathericons@1.0.0, @nuxtjs/svg@0.4.0
------------------------------

Reproduction

https://github.com/rmj-s/nuxt-bridge-test

Describe the bug

I'm trying to use Nuxt Bridge with Nuxt 2.17.0 but getting the following error on running the dev command:

 ERROR  Cannot start nuxt:  Cannot read properties of undefined (reading 'hook')                                                                                           

  at load (/node_modules/nuxi/dist/chunks/dev.mjs:209:41)
  at async Object.invoke (/node_modules/nuxi/dist/chunks/dev.mjs:248:5)
  at async _main (/node_modules/nuxi/dist/cli.mjs:48:20)

If I try to run the build command then I get the following error:

 ERROR  Nuxt instance is unavailable!                                                                                                                                      

  at useNuxt (/node_modules/@nuxt/kit/dist/index.mjs:31:11)
  at useNitro (/node_modules/@nuxt/kit/dist/index.mjs:2896:16)
  at Object.invoke (/node_modules/nuxi/dist/chunks/build.mjs:49:29)
  at async _main (/node_modules/nuxi/dist/cli.mjs:48:20)

Additional context

No response

Logs

No response

wattanx commented 1 year ago

You need to create nuxt.config.js and use defineNuxtConfig. https://nuxt.com/docs/bridge/overview#update-nuxtconfig

// nuxt.config.js
import { defineNuxtConfig } from '@nuxt/bridge';

export default defineNuxtConfig({});