nextjs - 💡(How to fix) Fix Turbopack build fails with symlinked node_modules: "Symlink node_modules is invalid, it points out of the filesystem root" [3 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#88335Fetched 2026-04-08 02:05:03
View on GitHub
Comments
3
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
commented ×3labeled ×2closed ×1issue_type_added ×1

Error Message

Build error occurred Error [TurbopackInternalError]: Symlink node_modules is invalid, it points out of the filesystem root

Debug info:

  • Execution of get_all_written_entrypoints_with_issues_operation failed
  • Execution of EntrypointsOperation::new failed
  • Execution of all_entrypoints_write_to_disk_operation failed
  • Execution of Project::emit_all_output_assets failed
  • Execution of *emit_assets failed
  • Execution of all_assets_from_entries_operation failed
  • Execution of *all_assets_from_entries failed
  • Execution of output_assets_operation failed
  • Execution of Project::get_all_endpoints failed
  • Execution of Project::get_all_endpoint_groups failed
  • Execution of Project::entrypoints failed
  • Execution of AppProject::routes failed
  • Execution of directory_tree_to_entrypoints_internal failed
  • Execution of try_get_next_package failed
  • Execution of *ResolveResult::first_source failed
  • Execution of resolve failed
  • Execution of resolve_internal failed
  • Execution of find_package failed
  • Symlink node_modules is invalid, it points out of the filesystem root at ignore-listed frames { type: 'TurbopackInternalError', location: undefined } ❌ Build failed. 🧹 Cleaning up workspace... Error: Command failed: next build at genericNodeError (node:internal/errors:985:15) at wrappedFn (node:internal/errors:539:14) at checkExecSyncError (node:child_process:925:11) at execSync (node:child_process:997:15) at build (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:88:5) at async <anonymous> (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:131:1) { status: 1, signal: null, output: [ null, null, null ], pid: 45856, stdout: null, stderr: null }

Code Example

git clone https://github.com/lobehub/lobe-chat.git
cd lobe-chat
pnpm install

---

mkdir -p tmp/test-build
cd tmp/test-build
ln -s ../../node_modules node_modules
ln -s ../../packages packages
cp ../../package.json .
cp ../../next.config.ts .
cp ../../tsconfig.json .
cp -r ../../src .

---

pnpm next build

---

FATAL: An unexpected Turbopack error occurred.
Error [TurbopackInternalError]: Symlink node_modules is invalid, it points out of the filesystem root

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0
Binaries:
  Node: 20.x
  pnpm: 10.x
Next.js:
  Version: 16.1.1
  Build mode: Turbopack (production build)

---

> Build error occurred
Error [TurbopackInternalError]: Symlink node_modules is invalid, it points out of the filesystem root

Debug info:
- Execution of get_all_written_entrypoints_with_issues_operation failed
- Execution of EntrypointsOperation::new failed
- Execution of all_entrypoints_write_to_disk_operation failed
- Execution of Project::emit_all_output_assets failed
- Execution of *emit_assets failed
- Execution of all_assets_from_entries_operation failed
- Execution of *all_assets_from_entries failed
- Execution of output_assets_operation failed
- Execution of Project::get_all_endpoints failed
- Execution of Project::get_all_endpoint_groups failed
- Execution of Project::entrypoints failed
- Execution of AppProject::routes failed
- Execution of directory_tree_to_entrypoints_internal failed
- Execution of try_get_next_package failed
- Execution of *ResolveResult::first_source failed
- Execution of resolve failed
- Execution of resolve_internal failed
- Execution of find_package failed
- Symlink node_modules is invalid, it points out of the filesystem root
    at ignore-listed frames {
  type: 'TurbopackInternalError',
  location: undefined
}
Build failed.
🧹 Cleaning up workspace...
Error: Command failed: next build
    at genericNodeError (node:internal/errors:985:15)
    at wrappedFn (node:internal/errors:539:14)
    at checkExecSyncError (node:child_process:925:11)
    at execSync (node:child_process:997:15)
    at build (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:88:5)
    at async <anonymous> (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:131:1) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 45856,
  stdout: null,
  stderr: null
}
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/lobehub/lobe-chat

To Reproduce

  1. Clone lobe-chat and install dependencies:
git clone https://github.com/lobehub/lobe-chat.git
cd lobe-chat
pnpm install
  1. Create a temporary build directory with symlinked node_modules:

See https://github.com/lobehub/lobe-chat/blob/5380f76ed1488936f508e755d106c49a22703b21/scripts/electronWorkflow/buildNextApp.mts

mkdir -p tmp/test-build
cd tmp/test-build
ln -s ../../node_modules node_modules
ln -s ../../packages packages
cp ../../package.json .
cp ../../next.config.ts .
cp ../../tsconfig.json .
cp -r ../../src .
  1. Run Next.js build with Turbopack:
pnpm next build
  1. Build fails with: Symlink node_modules is invalid, it points out of the filesystem root

Current vs. Expected behavior

Current behavior: Turbopack build fails with a fatal error when node_modules is a symlink pointing to a parent directory:

FATAL: An unexpected Turbopack error occurred.
Error [TurbopackInternalError]: Symlink node_modules is invalid, it points out of the filesystem root

Expected behavior: Turbopack should correctly resolve symlinked node_modules that point to parent directories, similar to how Webpack handles this scenario. This is a common pattern for:

  • Shadow/isolated builds in temporary directories
  • Monorepo setups with shared dependencies
  • Electron app builds that need modified source but shared node_modules Note: This worked fine with Webpack-based Next.js builds.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0
Binaries:
  Node: 20.x
  pnpm: 10.x
Next.js:
  Version: 16.1.1
  Build mode: Turbopack (production build)

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

Turbopack

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

next build (local)

Additional context

Use Case: Building an Electron desktop app that requires source code modifications but shares dependencies with the main project. The workflow creates a shadow/isolated build directory with symlinked node_modules to avoid duplicating ~1GB+ of dependencies.

Full Error Stack:


> Build error occurred
Error [TurbopackInternalError]: Symlink node_modules is invalid, it points out of the filesystem root

Debug info:
- Execution of get_all_written_entrypoints_with_issues_operation failed
- Execution of EntrypointsOperation::new failed
- Execution of all_entrypoints_write_to_disk_operation failed
- Execution of Project::emit_all_output_assets failed
- Execution of *emit_assets failed
- Execution of all_assets_from_entries_operation failed
- Execution of *all_assets_from_entries failed
- Execution of output_assets_operation failed
- Execution of Project::get_all_endpoints failed
- Execution of Project::get_all_endpoint_groups failed
- Execution of Project::entrypoints failed
- Execution of AppProject::routes failed
- Execution of directory_tree_to_entrypoints_internal failed
- Execution of try_get_next_package failed
- Execution of *ResolveResult::first_source failed
- Execution of resolve failed
- Execution of resolve_internal failed
- Execution of find_package failed
- Symlink node_modules is invalid, it points out of the filesystem root
    at ignore-listed frames {
  type: 'TurbopackInternalError',
  location: undefined
}
❌ Build failed.
🧹 Cleaning up workspace...
Error: Command failed: next build
    at genericNodeError (node:internal/errors:985:15)
    at wrappedFn (node:internal/errors:539:14)
    at checkExecSyncError (node:child_process:925:11)
    at execSync (node:child_process:997:15)
    at build (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:88:5)
    at async <anonymous> (/Users/innei/git/work/lobe-chat/scripts/electronWorkflow/buildNextApp.mts:131:1) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 45856,
  stdout: null,
  stderr: null
}

extent analysis

TL;DR

The most likely fix is to configure Turbopack to correctly resolve symlinked node_modules directories that point to parent directories.

Guidance

  • Verify that the node_modules symlink is correctly pointing to the parent directory and that the directory exists.
  • Check the Turbopack configuration to see if there are any options to enable resolving symlinks that point to parent directories.
  • Consider using a different build tool or configuration that supports resolving symlinks, such as Webpack.
  • Investigate if there are any known issues or limitations with Turbopack and symlinked node_modules directories.

Example

No code example is provided as the issue is related to configuration and build tools.

Notes

The issue seems to be specific to Turbopack and its handling of symlinked node_modules directories. The fact that it worked with Webpack-based Next.js builds suggests that the issue is not with the project setup, but rather with the build tool.

Recommendation

Apply a workaround, such as using a different build tool or configuration that supports resolving symlinks, until the issue is fixed in Turbopack. This is because the current behavior of Turbopack is causing a fatal error and preventing the build from completing.

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