question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuxt instance unavailable on all pages

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v16.14.0
  • Nuxt Version: 2.15.8
  • Package Manager: yarn@1.22.17
  • Builder: webpack
  • User Config: modules, buildModules, dev, build, css, meta, app, runtimeConfig
  • Runtime Modules: @nuxtjs/sitemap@2.4.0
  • Build Modules: nuxt-purgecss@1.0.0, ~/modules/pages

Reproduction

Start dev environment via yarn dev

Describe the bug

On every page I get the error

nuxt instance unavailable

  at useNuxtApp (./.nuxt/dist/server/server.mjs:587:13)
  at Module.useRuntimeConfig (./.nuxt/dist/server/server.mjs:595:10)
  at $id_bbf8dc5e (./.nuxt/dist/server/server.mjs:41284:38)
  at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:42697:3)

Additional context

I use useNuxtApp in app.vue

./app.vue

const nuxtApp = useNuxtApp()

nuxtApp.hook('page:finish', () => {
    window.scrollTo(0, 0)
})

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:26 (9 by maintainers)

github_iconTop GitHub Comments

12reactions
tiborpinocommented, Apr 20, 2022

@leccyril That’s a deliberate choice: #4016 (comment). Glad things are working for you after upgrade 😊

@tiborpino Are you still encountering this? Could you provide any answers to #4287 (comment)?

I’ve identified two problems and the error is now fixed

  1. We used to import like this import { useRuntimeConfig } from ‘#nitro’ - now not needed
  2. We use useRuntimeConfig outside defineNuxtPlugin
const config = useRuntimeConfig()
export default defineNuxtPlugin(() => {}

moved inside function solved the error

export default defineNuxtPlugin(() => {
    const config = useRuntimeConfig()
}
3reactions
Horpeycommented, Jul 11, 2022

If you have any imports in your component file from nuxt/app or #app, you can remove them, try to run the app and also generate it again to see if the error is gone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FATAL Nuxt instance is unavailable - Stack Overflow
I've just pulled from repo, ran npm install and then i run npm run dev now i get the error FATAL Nuxt instance...
Read more >
Commands and Deployment - Nuxt
Nuxt comes with a set of useful commands, both for development and production purpose.
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Nuxt scans the Vue files in the pages directory and outputs the appropriate pages. ... your app on the Vue instance and be...
Read more >
Error handling · Get Started with Nuxt
Rendering an Error Page ... When Nuxt encounters a fatal error, whether during the server lifecycle, or when rendering your Vue application (both...
Read more >
Using Modules and Pinia to structure Nuxt 3 app
These modules can contain their own components, composables, pages, plugins, and even a server middleware. By having all this modular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found