AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack Fails To Resolve Next/Package.Json When Pnpm V11 EnableGlobalVirtualStore Creates Symlink Outside Project Root

With pnpm v11's enableGlobalVirtualStore enabled, node_modules/next is a symlink to a global store outside the project root. Turbopack's filesystem resolution restricts access to the project root, causing 'Couldn't find the Next.js package' in dev mode. Webpack works; this is a Turbopack-specific limitation.

highConfidence 85%Next.jsAffected V16.2.4Affected Vcanary

Origin Analysis

Turbopack enforces a filesystem root (defaulting to project directory) and fails to resolve the real path of symlinked packages like next when pnpm global virtual store places them outside that root, leading to inability to locate next/package.json.
1. Use pnpm v11. 2. Set enableGlobalVirtualStore: true in pnpm-workspace.yaml. 3. Install dependencies with pnpm install. 4. Run next dev (Turbopack enabled by default). 5. Open any app route; dev server fails with error about missing next/package.json.

Fixing Code Block

Edge Case Audit

Setting turbopack.root to a broad directory (e.g., user home) can cause Turbopack to watch and process unrelated files, leading to performance degradation, memory overhead, and potential unintended module resolution. On Windows, path handling and symlink semantics differ; test thoroughly. In monorepos with multiple projects, the common root may become too broad. If issues arise, remove this configuration and either disable enableGlobalVirtualStore or use webpack dev mode. This is not an official fix; future Next.js versions may handle symlinks natively, making this workaround unnecessary.

Ecosystem Topology