Link to the code that reproduces this issue
https://github.com/taracutie/nextjs-turbopack-repro
To Reproduce
git clone https://github.com/taracutie/nextjs-turbopack-repro
cd nextjs-turbopack-repro && npm ci
npm run build
Current vs. Expected behavior
Current
The build step fails resolving a path that is not an import.
▲ Next.js 16.4.0-canary.8 (Turbopack)
> Build error occurred
Error: Turbopack build failed with 1 error:
./lib/spawn-it.ts:6:10
Error: Module not found: Can't resolve '/ROOT/worker.mjs'
4 | export function spawnWorker() {
5 | const script = path.join(process.cwd(), "worker.mjs");
> 6 | return fork(script, []);
| ^^^^^^^^^^^^^^^^
Import trace:
App Route:
./lib/spawn-it.ts
./app/api/x/route.ts
first argument to fork() |
result |
path.join(process.cwd(), "worker.mjs") |
Can't resolve '/ROOT/worker.mjs' |
"/tmp/worker-abs.mjs" (absolute literal, exists) |
Can't resolve '/tmp/worker-abs.mjs' |
process.env.WORKER_PATH ?? "" |
Can't resolve (<dynamic> | '') |
process.env.WORKER_PATH (no constant part) |
builds |
spawn(script, []) and execFile(script, []) with the same exact path build fine.
Expected
The build succeeds.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026
Available memory (MB): 15614
Available CPU cores: 8
Binaries:
Node: 26.7.0
npm: 11.19.0
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.4.0-canary.8 // Latest available version is detected (16.4.0-canary.8).
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack, Module Resolution
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Fails on 16.0.0-canary.0, 16.0.0, 16.3.3, 16.4.0-canary.7 and 16.4.0-canary.8
Link to the code that reproduces this issue
https://github.com/taracutie/nextjs-turbopack-repro
To Reproduce
git clone https://github.com/taracutie/nextjs-turbopack-reprocd nextjs-turbopack-repro && npm cinpm run buildCurrent vs. Expected behavior
Current
The build step fails resolving a path that is not an import.
fork()path.join(process.cwd(), "worker.mjs")Can't resolve '/ROOT/worker.mjs'"/tmp/worker-abs.mjs"(absolute literal, exists)Can't resolve '/tmp/worker-abs.mjs'process.env.WORKER_PATH ?? ""Can't resolve (<dynamic> | '')process.env.WORKER_PATH(no constant part)spawn(script, [])andexecFile(script, [])with the same exact path build fine.Expected
The build succeeds.
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 Available memory (MB): 15614 Available CPU cores: 8 Binaries: Node: 26.7.0 npm: 11.19.0 Yarn: N/A pnpm: N/A Relevant Packages: next: 16.4.0-canary.8 // Latest available version is detected (16.4.0-canary.8). eslint-config-next: N/A react: 19.2.8 react-dom: 19.2.8 typescript: 5.9.3 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
Turbopack, Module Resolution
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Fails on
16.0.0-canary.0,16.0.0,16.3.3,16.4.0-canary.7and16.4.0-canary.8