canirequire › Dual (CommonJS + ESM) › through2
Is through2 ESM-only? Can you require() it?
Tiny utilities for inserting transformation logic into Node.js stream and Web Streams pipelines
Last verified Sep 9, 2026 against through2@5.0.11. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
through2 publishes both a CommonJS entry and a native ESM entry (ESM added in 5.0.0). require("through2") and import "through2" both work on every supported Node.js version and in Bun.
Does through2@5.0.11 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("through2") from a CommonJS file and import "through2" from an ES module.
| Runtime | require("through2") | import "through2" |
|---|---|---|
| Node.js 18 | ✗ failsERR_REQUIRE_ESM | ✓ works |
| Node.js 20 | ✓ works | ✓ works |
| Node.js 22 | ✓ works | ✓ works |
| Node.js 24 | ✓ works | ✓ works |
| Node.js 26 | ✓ works | ✓ works |
| Bun 1.4 | ✓ works | ✓ works |
A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.
How to import through2
ES modules (import)
import through2 from "through2";CommonJS (require)
const through2 = require("through2");Module format by version
Derived from the type, main and exports fields of every stable release on npm (50 versions; the newest 50 shown).
| Versions | Format | First published |
|---|---|---|
| 5.0.1 – 5.0.11 | Dual (CommonJS + ESM) | May 15, 2026 |
| 5.0.0 | ESM-only | May 7, 2026 |
| 0.0.0 – 4.0.2 | CommonJS | Aug 1, 2013 |
Frequently asked
Is through2 ESM-only?
through2@5.0.11 ships CommonJS and ESM builds. through2 publishes both a CommonJS entry and a native ESM entry (ESM added in 5.0.0). require("through2") and import "through2" both work on every supported Node.js version and in Bun.
Can I require through2?
Yes. through2 ships a CommonJS entry, so require("through2") works on every Node.js version, alongside the native ESM entry for import.
Does through2 work in Bun?
Yes. import "through2" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does through2 ship TypeScript types?
Yes. through2 bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- hoist-non-react-statics 3.3.2CommonJS
- requires-port 1.0.0CommonJS
- luxon 3.7.2Dual
- jest-runtime 30.5.1Dual
- import-local 3.2.0CommonJS
- bser 2.1.1CommonJS
- eslint-plugin-prettier 5.5.6CommonJS
- svgo 4.1.0Dual