Turbopack fails to resolve next/package.json with pnpm v11 enableGlobalVirtualStore
Link to the code that reproduces this issue
https://github.com/yamaaaaaa31/turbopack-pnpm-v11-repro
To Reproduce
- Clone the reproduction repository.
- Use pnpm v11.
- Make sure pnpm global virtual store is enabled:
# pnpm-workspace.yaml
enableGlobalVirtualStore: true
- Install dependencies:
pnpm install
- Start the development server with Turbopack:
pnpm dev
- Open the app route in the browser.
Current vs. Expected behavior
When enableGlobalVirtualStore: true is enabled in pnpm v11, node_modules/next is a symlink whose real path points outside the project root, for example:
node_modules/next -> ~/Library/pnpm/store/v11/links/.../node_modules/next
With Turbopack, next dev fails when serving the app because it cannot resolve next/package.json:
Couldn't find the Next.js package (next/package.json)
from project directory: <project>/src/app
Expected behavior: Turbopack should handle pnpm v11 global virtual store symlinks for normal runtime dependencies, including Next.js itself, or provide a clear error/workaround.
This does not happen when using webpack dev mode.
Additional verification:
- This also reproduces with
next@canary. - This is not specific to
output: "standalone". The linked reproduction does not setoutput: "standalone"and still reproduces. - Setting
experimental.externalDir: truedoes not address this. The failure appears to happen at Turbopack's filesystem root / symlink resolution layer, before regular external source imports.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.4.0
Available memory (MB): 49152
Available CPU cores: 14
Binaries:
Node: 22.22.2
npm: 10.9.7
Yarn: N/A
pnpm: 11.0.6
Relevant Packages:
next: 16.2.4
eslint-config-next: N/A
react: 19.2.5
react-dom: 19.2.5
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
This seems related to pnpm v11's enableGlobalVirtualStore: true.
In this setup, realpath(node_modules/next/package.json) points outside the project root. Setting turbopack.root to the app root is not enough. A workaround is to set turbopack.root to the common ancestor of the app root and the real path of node_modules/next/package.json, but that can become a very broad directory such as the user's home directory.
Workarounds observed:
pnpm dev --webpackworks.- Disabling
enableGlobalVirtualStoreavoids the issue. - Setting
turbopack.rootto the common ancestor of the app root andrealpath(node_modules/next/package.json)works, but in real projects this can require broadening the root to a directory like the user's home directory, which is not a practical default.
Related issues / PRs:
Source: vercel/next.js