nextjs - ✅(Solved) Fix Turbopack does not support imports from stream/consumers [1 pull requests, 4 comments, 4 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#90765Fetched 2026-04-08 00:19:34
View on GitHub
Comments
4
Participants
4
Timeline
16
Reactions
0
Timeline (top)
commented ×4labeled ×3referenced ×2closed ×1

Error Message

  1. Attempt to build the code using Turbopack: npm run build — the error Module not found: Can't resolve 'stream/consumers' will be displayed
  2. Attempt to build the code using Turbopack: npm run build — the error Cannot find module 'node:stream/consumers': Unsupported external type Url for commonjs reference will be displayed

Fix Action

Fixed

PR fix notes

PR #90819: Unify Node and Edge externals list

Description (problem / solution / changelog)

Unify the list of Node/Edge iexternals. Turns out readline/promises and stream/consumers was missing in some places.

Closes https://github.com/vercel/next.js/issues/90765

Changed files

  • Cargo.lock (modified, +1/-0)
  • crates/next-core/src/next_import_map.rs (modified, +8/-58)
  • crates/next-custom-transforms/Cargo.toml (modified, +1/-0)
  • crates/next-custom-transforms/src/transforms/warn_for_edge_runtime.rs (modified, +7/-74)
  • crates/next-taskless/src/constants.rs (modified, +54/-16)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:30:44 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.21.1
  npm: 11.10.0
  Yarn: 1.22.22
  pnpm: 10.28.0
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/paulbrimicombe/nextjs-stream-consumers-bug

To Reproduce

  1. Install dependencies: npm install
  2. Attempt to build the code using Turbopack: npm run build — the error Module not found: Can't resolve 'stream/consumers' will be displayed
  3. Attempt to build the code using Webpack: npm run build -- --webpack — no errors will be shown
  4. Update the code in page.tsx to add the node: prefix to the stream/consumers import
  5. Attempt to build the code using Turbopack: npm run build — the error Cannot find module 'node:stream/consumers': Unsupported external type Url for commonjs reference will be displayed

Current vs. Expected behavior

  • Utility consumer functions should be able to be imported without the node: prefix (like other Node.js libraries).
  • These functions should be able to be imported in CommonJS code

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:30:44 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.21.1
  npm: 11.10.0
  Yarn: 1.22.22
  pnpm: 10.28.0
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  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)

next build (local)

Additional context

A quick search of the Turbopack codebase for similar Node.js libraries such as stream/promises or stream/web indicates that there is some missing handling for stream/consumers.

extent analysis

Fix Plan

To resolve the issue with importing stream/consumers in Turbopack, we need to add a custom resolver for Node.js built-in modules.

Here are the steps:

  • Create a custom resolver function in next.config.js:
module.exports = {
  //... other configurations ...
  turbopack: {
    resolve: {
      alias: {
        'stream/consumers': 'node:stream/consumers',
      },
    },
  },
}

Alternatively, you can use the node: prefix when importing the module:

import { TextDecoder, TextEncoder } from 'node:util';
import { pipe } from 'node:stream/consumers';

However, this approach may not be desirable if you want to maintain consistency with other Node.js libraries.

Verification

To verify that the fix worked, run the following command:

npm run build

If the build is successful, it means that the custom resolver is working correctly.

Extra Tips

Note that this fix is specific to Turbopack and may not be necessary when using other build tools like Webpack. Additionally, you may need to update your tsconfig.json file to include the node option in the compilerOptions.paths section:

{
  "compilerOptions": {
    //... other configurations ...
    "paths": {
      "node:*": ["node_modules/@types/node/*"]
    }
  }
}

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING