Link to the code that reproduces this issue
https://github.com/mausferd/turbopack-pnpm-app-router-repro
To Reproduce
git clone https://github.com/mausferd/turbopack-pnpm-app-router-repro && cd turbopack-pnpm-app-router-repro
pnpm install
cd apps/web && pnpm dev (uses Turbopack — the default)
Current vs. Expected behavior
Expected: Next 16.2.3 starts the dev server. turbopack.root is set in apps/web/next.config.mjs to an absolute path pointing at apps/web, so Turbopack should use apps/web as the project root, find apps/web/node_modules/next/package.json via the standard pnpm symlink, and serve app/page.tsx.
Actual: dev server reports Ready in ~170ms, then immediately crashes with:
Error: Turbopack build failed with 1 errors:
./app
Error: Next.js inferred your workspace root, but it may not be correct.
We couldn't find the Next.js package (next/package.json) from the project directory: /private/tmp/turbopack-pnpm-app-router-repro/apps/web/app
To fix this, set turbopack.root in your Next.js config, or ensure the Next.js package is resolvable from this directory.
Two things to note in the error message:
- The "project directory" is
apps/web/app, not apps/web. Turbopack is treating the App Router app/ folder as the project root. app/ is the Next.js App Router routes directory — it should never be inferred as a project root.
turbopack.root IS set in apps/web/next.config.mjs:
import { fileURLToPath } from 'node:url'
import { dirname } from 'node:path'
const __dirname = dirname(fileURLToPath(import.meta.url))
export default {
turbopack: { root: __dirname }, // /…/apps/web (absolute)
outputFileTracingRoot: __dirname,
}
Both turbopack.root and outputFileTracingRoot are pinned to absolute apps/web, but Turbopack ignores them and still reports apps/web/app as the project directory. The error message advises setting turbopack.root — which is already set.
Workaround
next dev --webpack works perfectly with the same structure:
cd apps/web && pnpm dev:webpack
✓ Ready in 263ms
So the bug is Turbopack-specific. Webpack mode honours the workspace correctly.
Provide environment information
- OS: macOS Darwin 25.3.0 (arm64)
- Node.js: v22.x
- pnpm: 9.15.0
- next: 16.2.3
- react: 19.2.4
- react-dom: 19.2.4
- Router: App Router
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Link to the code that reproduces this issue
https://github.com/mausferd/turbopack-pnpm-app-router-repro
To Reproduce
git clone https://github.com/mausferd/turbopack-pnpm-app-router-repro && cd turbopack-pnpm-app-router-repropnpm installcd apps/web && pnpm dev(uses Turbopack — the default)Current vs. Expected behavior
Expected: Next 16.2.3 starts the dev server.
turbopack.rootis set inapps/web/next.config.mjsto an absolute path pointing atapps/web, so Turbopack should useapps/webas the project root, findapps/web/node_modules/next/package.jsonvia the standard pnpm symlink, and serveapp/page.tsx.Actual: dev server reports
Ready in ~170ms, then immediately crashes with:Two things to note in the error message:
apps/web/app, notapps/web. Turbopack is treating the App Routerapp/folder as the project root.app/is the Next.js App Router routes directory — it should never be inferred as a project root.turbopack.rootIS set inapps/web/next.config.mjs:turbopack.rootandoutputFileTracingRootare pinned to absoluteapps/web, but Turbopack ignores them and still reportsapps/web/appas the project directory. The error message advises settingturbopack.root— which is already set.Workaround
next dev --webpackworks perfectly with the same structure:So the bug is Turbopack-specific. Webpack mode honours the workspace correctly.
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
file:deps, no custom resolver.apps/web/node_modules/nextresolves correctly via the standard pnpm symlink (../../../node_modules/.pnpm/next@16.2.3.../next).next@16.1.6(no such issue) to16.2.3.file:package, not pnpm workspace).