canirequire

canirequireDual (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.

Latest
5.0.11 (Jul 30, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.0.11
Native ESM since
5.0.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
34.1M
License
MIT

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.

Runtimerequire("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).

VersionsFormatFirst published
5.0.1 – 5.0.11Dual (CommonJS + ESM)May 15, 2026
5.0.0ESM-onlyMay 7, 2026
0.0.0 – 4.0.2CommonJSAug 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

Similar popularity