nextjs - ✅(Solved) Fix Segment Explorer can't Open in Editor when Next.js app is part of a monorepo [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85695Fetched 2026-04-08 02:14:18
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
3
Timeline (top)
subscribed ×5commented ×1cross-referenced ×1issue_type_added ×1

Error Message

I expect my editor (in my case, Visual Studio Code) to open the selected file. Instead, nothing happens. Inspecting Chrome Dev Tools, I see a 404 error from a request to http://localhost:3001/__nextjs_launch-editor?file=%2Fapps%2Fdocs%2Fapp%2Flayout.tsx&isAppRelativePath=1.

Root Cause

I tried changing turbopack.root in next.config.ts, assuming that this is being defaulted to the monorepo root due to where pnpm-lock.yaml is placed. Unfortunately, this causes other issue, namely that Turbopack can no longer resolve next/package.json (probably because of how pnpm symlinks packages).

Fix Action

Fixed

PR fix notes

PR #91989: fix(dev-overlay): resolve Segment Explorer editor paths in monorepos

Description (problem / solution / changelog)

Summary

  • normalize app-relative editor paths before opening files from the Segment Explorer
  • strip leading monorepo segments so paths like apps/docs/app/layout.tsx resolve back to app/... or src/app/...
  • fix the existing src/app path ordering bug by rewriting cross-prefix inputs in both directions

Testing

  • corepack pnpm exec prettier --check packages/next/src/server/dev/resolve-app-relative-editor-path.ts packages/next/src/server/dev/resolve-app-relative-editor-path.test.ts packages/next/src/server/dev/middleware-turbopack.ts packages/next/src/server/dev/middleware-webpack.ts
  • corepack pnpm exec eslint --config eslint.cli.config.mjs packages/next/src/server/dev/resolve-app-relative-editor-path.ts packages/next/src/server/dev/resolve-app-relative-editor-path.test.ts packages/next/src/server/dev/middleware-turbopack.ts packages/next/src/server/dev/middleware-webpack.ts
  • corepack pnpm lint-staged
  • git diff --check
  • node --experimental-strip-types runtime assertions for monorepo, src/app, and Windows-separator cases

Fixes #85695

Changed files

  • packages/next/src/server/dev/middleware-turbopack.ts (modified, +2/-5)
  • packages/next/src/server/dev/middleware-webpack.ts (modified, +2/-5)
  • packages/next/src/server/dev/resolve-app-relative-editor-path.test.ts (added, +45/-0)
  • packages/next/src/server/dev/resolve-app-relative-editor-path.ts (added, +32/-0)

Code Example

Operating System:
  Platform: linux
  Arch: arm64
  Version: #1 SMP Thu Aug 14 19:26:13 UTC 2025
  Available memory (MB): 15973
  Available CPU cores: 12
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.0.0
Relevant Packages:
  next: 16.0.2-canary.4 // Latest available version is detected (16.0.2-canary.4).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/turborepo/tree/main/examples/basic

To Reproduce

  1. Use npx create-turbo@latest as instructed in the example's README
  2. Select pnpm as the package manager
  3. Start the apps using pnpm dev
  4. Open the docs site at https://localhost:3001
  5. Open the Segment Explorer from the Next.js Dev Tools (click the button in the bottom left corner and select Route Info)
  6. Hover over either layout.tsx or page.tsx, then click on the code icon

Current vs. Expected behavior

I expect my editor (in my case, Visual Studio Code) to open the selected file. Instead, nothing happens. Inspecting Chrome Dev Tools, I see a 404 error from a request to http://localhost:3001/__nextjs_launch-editor?file=%2Fapps%2Fdocs%2Fapp%2Flayout.tsx&isAppRelativePath=1.

Provide environment information

Operating System:
  Platform: linux
  Arch: arm64
  Version: #1 SMP Thu Aug 14 19:26:13 UTC 2025
  Available memory (MB): 15973
  Available CPU cores: 12
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.0.0
Relevant Packages:
  next: 16.0.2-canary.4 // Latest available version is detected (16.0.2-canary.4).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.1.0
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Notably, the path given to /__nextjs_launch-editor is from the root of the monorepo rather than from the Next.js app's app directory, which I think is what's causing the issue, given this code:

https://github.com/vercel/next.js/blob/138c9ae62a78f699570b04be0c6132a4ad9606a8/packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx#L444-L456

https://github.com/vercel/next.js/blob/138c9ae62a78f699570b04be0c6132a4ad9606a8/packages/next/src/server/dev/middleware-turbopack.ts#L367-L379

As instructed by next info, I updated to the latest canary version of Next.js and was still able to reproduce the issue.

I tried changing turbopack.root in next.config.ts, assuming that this is being defaulted to the monorepo root due to where pnpm-lock.yaml is placed. Unfortunately, this causes other issue, namely that Turbopack can no longer resolve next/package.json (probably because of how pnpm symlinks packages).

extent analysis

TL;DR

The issue can be resolved by correctly configuring the turbopack.root in next.config.ts to point to the Next.js app's directory instead of the monorepo root.

Guidance

  • Verify that the turbopack.root configuration is correctly set to the app directory, as the current setting seems to be defaulting to the monorepo root.
  • Check the next.config.ts file for any existing turbopack.root configuration and update it to point to the correct directory.
  • If updating turbopack.root causes issues with Turbopack resolving next/package.json, consider adjusting the pnpm configuration or symlinks to ensure correct package resolution.
  • Review the Next.js documentation and source code (e.g., segment-explorer.tsx and middleware-turbopack.ts) to ensure correct usage and configuration of the __nextjs_launch-editor endpoint.

Example

No code example is provided due to the complexity of the issue and the need for specific configuration adjustments.

Notes

The issue seems to be related to the configuration of turbopack.root and its impact on the __nextjs_launch-editor endpoint. The correct configuration will depend on the specific monorepo and Next.js app directory structure.

Recommendation

Apply a workaround by adjusting the turbopack.root configuration in next.config.ts to point to the correct app directory, and then troubleshoot any resulting issues with package resolution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING