nextjs - ✅(Solved) Fix [Turbopack Nextjs 16]: Pino - Cannot find module './transport-stream' [1 pull requests, 46 comments, 25 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#86099Fetched 2026-04-08 02:07:10
View on GitHub
Comments
46
Participants
25
Timeline
183
Reactions
46

Error Message

Uncaught Exception: Error: Cannot find module './transport-stream' Require stack:

  • /var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js at Module._resolveFilename (node:internal/modules/cjs/loader:1420:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1058:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1063:22) at Module._load (node:internal/modules/cjs/loader:1226:37) at TracingChannel.traceSync (node:diagnostics_channel:328:14) at wrapModuleLoad (node:internal/modules/cjs/loader:244:24) at Module.require (node:internal/modules/cjs/loader:1503:12) at a (/opt/rust/bytecode.js:2:1094) at Object.<anonymous> (/var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js:7:36) at Module.<anonymous> (/opt/rust/bytecode.js:2:1435)

Fix Action

Fix / Workaround

Summary: Discussions in this issue have diverged a bit, and there are mainly two cases:

  1. Turbopack + non-Vercel deployment. Broken since v16.0.3 due to Turbopack starts to trace worker_threads (fixed #84766).
    • Errors (include but not limited to):
      • Parsing ecmascript source code failed (License file) - comment1
      • Can't resolve 'why-is-node-running'/'tap'/etc. (require statement) - comment2, comment3
    • Workaround:
      • Switch back to Webpack. next build --webpack
      • Or add pino, thread-stream and related pino transport target packages to serverExternalPackages, you might also need to add thread-stream as a dependency explicitly.
    • Fixed: since v16.1.0-canary.16 by #86375 and #86884
  2. Turbopack + Vercel deployement. This is the original case of this issue. Turbopack never works in this setup, #84766 was fixed in v16.0.3, and now #86099 is waiting for a fix. The fixes above doesn't work for this case (see https://github.com/vercel/next.js/issues/86099#issuecomment-3629882719). The only workaround is to use Webpack next build --webpack with serverExternalPackages, see Notes below.

PR fix notes

PR #16: Fix build and proxy

Description (problem / solution / changelog)

(No description)

Changed files

  • .github/workflows/sanity-build.yaml (modified, +10/-17)
  • next.config.ts (modified, +1/-0)
  • proxy.ts (renamed, +1/-1)

Code Example

Uncaught Exception: Error: Cannot find module './transport-stream'
Require stack:
- /var/task/node_modules/.pnpm/pino@10.1.0/node_modules/pino/lib/worker.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1420:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1058:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1063:22)
    at Module._load (node:internal/modules/cjs/loader:1226:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
    at Module.require (node:internal/modules/cjs/loader:1503:12)
    at a (/opt/rust/bytecode.js:2:1094)
    at Object.<anonymous> (/var/task/node_modules/.pnpm/pino@10.1.0/node_modules/pino/lib/worker.js:7:36)
    at Module.<anonymous> (/opt/rust/bytecode.js:2:1435)

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025
  Available memory (MB): 15839
  Available CPU cores: 20
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.24.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Summary: Discussions in this issue have diverged a bit, and there are mainly two cases:

  1. Turbopack + non-Vercel deployment. Broken since v16.0.3 due to Turbopack starts to trace worker_threads (fixed #84766).
    • Errors (include but not limited to):
      • Parsing ecmascript source code failed (License file) - comment1
      • Can't resolve 'why-is-node-running'/'tap'/etc. (require statement) - comment2, comment3
    • Workaround:
      • Switch back to Webpack. next build --webpack
      • Or add pino, thread-stream and related pino transport target packages to serverExternalPackages, you might also need to add thread-stream as a dependency explicitly.
    • Fixed: since v16.1.0-canary.16 by #86375 and #86884
  2. Turbopack + Vercel deployement. This is the original case of this issue. Turbopack never works in this setup, #84766 was fixed in v16.0.3, and now #86099 is waiting for a fix. The fixes above doesn't work for this case (see https://github.com/vercel/next.js/issues/86099#issuecomment-3629882719). The only workaround is to use Webpack next build --webpack with serverExternalPackages, see Notes below.

Notes: From comment9

Pino is way too dynamic for Turbopack to be able to figure out all required files automatically: pinojs/pino@7dd79a3/lib/transport.js#L94

Pino itself has a documentation that talks about bundling, and there were already problems since Webpack + Vercel deployment, see comment10.

Also for in−depth details: https://github.com/pinojs/thread-stream/issues/184


Link to the code that reproduces this issue

https://github.com/CHC383/nextjs-turbopack-pino-reproduction

To Reproduce

  1. Deploy the code to Vercel
  2. Visit <url>/api/log
  3. Check the log of the Vercel deployment

Current vs. Expected behavior

Current behavior

With Turbopack in NextJs v16, Pino worker thread throws the following error:

Uncaught Exception: Error: Cannot find module './transport-stream'
Require stack:
- /var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1420:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1058:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1063:22)
    at Module._load (node:internal/modules/cjs/loader:1226:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
    at Module.require (node:internal/modules/cjs/loader:1503:12)
    at a (/opt/rust/bytecode.js:2:1094)
    at Object.<anonymous> (/var/task/node_modules/.pnpm/[email protected]/node_modules/pino/lib/worker.js:7:36)
    at Module.<anonymous> (/opt/rust/bytecode.js:2:1435)

Expected behavior

Pino worker thread works without any exception, which is the behavior of using WebPack.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025
  Available memory (MB): 15839
  Available CPU cores: 20
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.24.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
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)

Vercel (Deployed)

Additional context

@mischnic This is a follow up of #84766. It seems that with multiple targets, the pino/lib/worker.js is used and not traced by Turbopack properly. I have updated the reproduction code to trigger the new error.

extent analysis

TL;DR

To fix the issue with Turbopack and Pino in Next.js, switch to Webpack by running next build --webpack or add pino, thread-stream, and related packages to serverExternalPackages.

Guidance

  • For non-Vercel deployments, add pino, thread-stream, and related packages to serverExternalPackages to resolve the issue with Turbopack.
  • For Vercel deployments, the only workaround is to use Webpack by running next build --webpack with serverExternalPackages.
  • Verify the fix by checking the log of the Vercel deployment after making the changes.
  • Consider pinning package versions to avoid conflicts, as mentioned in the issue comments.

Example

No explicit code example is provided, but the issue comments mention setting serverExternalPackages and installing thread-stream as a dependency.

Notes

The issue is specific to Turbopack and Pino in Next.js, and the fixes may not work for all cases. Pino's dynamic nature makes it challenging for Turbopack to figure out all required files automatically.

Recommendation

Apply the workaround by switching to Webpack using next build --webpack for Vercel deployments, as the fixes for Turbopack are not yet available for this specific case. For non-Vercel deployments, adding pino, thread-stream, and related packages to serverExternalPackages may resolve the issue.

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…

FAQ

Expected behavior

Pino worker thread works without any exception, which is the behavior of using WebPack.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix [Turbopack Nextjs 16]: Pino - Cannot find module './transport-stream' [1 pull requests, 46 comments, 25 participants]