nuxt / nuxt/devtools

fix: Cannot start nuxt: Failed to get devtools context

Open
#702 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.3k
Forks
214
Avg merge
13h 22m
Merged PRs (30d)
18

Description

🐛 The bug

When using (the latest version of) Nuxt Devtools and Nuxt Seo, Nuxt won't start in dev mode. See also https://github.com/harlan-zw/nuxt-seo/issues/242

// package.json
{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxtjs/seo": "^2.0.0-rc.16",
    "nuxt": "^3.12.4",
    "vue": "latest"
  }
}
// nuxt.config.ts
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  modules: ["@nuxtjs/seo"]
})

Gives error

 ERROR  Cannot start nuxt:  Failed to get devtools context.                                                                                                                                                                                                                                                                               12:05:49 PM

  at extendServerRpc (node_modules/@nuxt/devtools-kit/dist/index.mjs:96:11)
  at node_modules/@nuxtjs/robots/dist/module.mjs:167:5
  at node_modules/hookable/dist/index.mjs:48:66
  at Object.run (node_modules/hookable/dist/index.mjs:41:43)
  at node_modules/hookable/dist/index.mjs:48:56
  at async enableModule (/Users/remihuigen/.nvm/versions/node/v16.19.1/lib/node_modules/@nuxt/devtools/dist/chunks/module-main.mjs:8466:3)
  at async normalizedModule (/Users/remihuigen/.nvm/versions/node/v16.19.1/lib/node_modules/@nuxt/devtools/node_modules/@nuxt/kit/dist/index.mjs:169:17)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2468:95)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:4496:5)
  at async NuxtDevServer._load (node_modules/nuxi/dist/chunks/dev2.mjs:6875:5)

The stackblitz reproduction is giving a different error though (it wont start either)

[12:11:04]  ERROR  [worker reload] [worker init] Cannot find package '@css-inline/css-inline-wasm' imported from /home/projects/nuxt-starter-rbifnw/.nuxt/dev/index.mjs

  at __node_internal_captureLargerStackTrace2 (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:101:5335)
  at new NodeError (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:101:4149)
  at packageResolve (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:158:9724)
  at moduleResolve (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:158:10188)
  at defaultResolve (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:158:12372)
  at ModuleLoader.defaultResolve (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:154:3284)
  at ModuleLoader.resolve (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:154:2989)
  at ModuleLoader.getModuleJob (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:154:1938)
  at https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:155:1047
  at _0x25ddf3.link (https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/blitz.41692973.js:40:796147)
  at https://nuxtstarterrbifnw-capv.w-credentialless-staticblitz.com/builtins.1003299b.js:155:1002
🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-rbifnw?file=nuxt.config.ts

🌈 Expected behavior

I excepted the dev server to start with devtools enabled :)

ℹ️ Additional context

I first reported this bug in the nuxt seo repo, but according to @harlan-zw it's an upstream issue...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using package.json and nuxt.config.ts with Nuxt Devtools and @nuxtjs/seo enabled. Start with the extendServerRpc stack entry in @nuxt/devtools-kit and the @nuxtjs/robots call site, then compare the local and StackBlitz errors. Done means the Nuxt development server starts with devtools enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.