Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fix: workspace-relative openInEditor paths resolve against cwd and double the package prefix in monorepos

Aperta
#1,097 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
nuxtjs, typescript

Direzione di ricerca

Start at the openInEditor entry point described in the issue and inspect how process.cwd(), nuxt.options.workspaceDir, and the existsSync check are used before openInEditorHooks. Reproduce with a pnpm workspace app under apps/web on Windows, then verify that the workspace-relative path opens the expected file and hooks are not blocked by an early failure.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
🐛 The bug

In a pnpm monorepo, Component Inspector → Open in Editor fails with a doubled package path:

File not found: <repo>/apps/web/apps/web/app/features/.../SomeComponent.vue

Expected file:

<repo>/apps/web/app/features/.../SomeComponent.vue

(Same pattern for any package under apps/<name>/, e.g. previously apps/appapps/app/apps/app/....)

Why

openInEditor resolves non-absolute paths with process.cwd() (the Nuxt package root, e.g. apps/web):

if (input.startsWith("./") || !ABSOLUTE_PATH_RE.test(input))
  input = resolve(process.cwd(), input)

The inspector often sends a workspace-relative path like:

apps/web/app/features/.../SomeComponent.vue

So:

cwd (= …/apps/web) + apps/web/app/...  →  …/apps/web/apps/web/app/...

existsSync then fails and returns before openInEditorHooks run, so hooks cannot fix the path.

Nuxt already exposes nuxt.options.workspaceDir for monorepos, but it is not used here.

🛠️ To reproduce

pnpm monorepo with Nuxt at apps/web → pnpm --filter dev (cwd=apps/web) → Component Inspector → Open in Editor → File not found with doubled apps/web/apps/web/...

🌈 Expected behavior

Resolve relative open-in-editor paths against nuxt.options.workspaceDir (and/or try cwdrootDirworkspaceDir and pick the first path that exists), then open the file.

Ideally openInEditorHooks should also run (or path normalization should happen) before the hard existsSync failure, so consumers can fix monorepo paths.

ℹ️ Additional context
Detailed reproduction
  1. pnpm workspace with Nuxt app at apps/web (not repo root).
  2. Run pnpm --filter <app> dev so process.cwd() is apps/web.
  3. Enable Component Inspector, click a component, Open in Editor.
  4. Observe File not found: …/apps/web/apps/web/app/....

Minimal layout:

repo/
  pnpm-workspace.yaml   # packages: ['apps/*']
  apps/
    web/                # Nuxt app (cwd when running nuxt dev)
      app/
        components/
          Foo.vue
Environment
  • Nuxt: 4.5.x
  • @nuxt/devtools: 3.4.x (via Nuxt)
  • Package manager: pnpm workspace
  • OS: Windows 10/11
Workaround

Local Nuxt module wrapping the DevTools RPC openInEditor to rewrite the path (try cwd / rootDir / workspaceDir + undouble apps/<pkg>/apps/<pkg>/…) before calling the original handler.

Also set:

// nuxt.config.ts
workspaceDir: fileURLToPath(new URL('../..', import.meta.url)), // monorepo root
Related
Lingua principale
TypeScript
Stelle
3.3k
Fork
214
Merge medio
19h 45m
PR unite (30g)
12

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nuxt/devtools

Tutte le issue di nuxt/devtools

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.