canirequire

canirequireCommonJS › end-of-stream

Is end-of-stream ESM-only? Can you require() it?

Call a callback when a readable/writable/duplex stream has completed or failed.

Last verified Sep 9, 2026 against end-of-stream@1.4.5. JSON

CommonJS CommonJS — require() works on every Node.js version

end-of-stream ships CommonJS only. require("end-of-stream") works everywhere. import "end-of-stream" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
1.4.5 (Jun 16, 2025)
Module format
CommonJS
Last CommonJS version
1.4.5
TypeScript types
@types/end-of-stream
Node engines
not declared
Weekly downloads
69.7M
License
MIT

Does end-of-stream@1.4.5 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("end-of-stream") from a CommonJS file and import "end-of-stream" from an ES module.

Runtimerequire("end-of-stream")import "end-of-stream"
Node.js 18✓ works✓ 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

How to import end-of-stream

ES modules (import)

import endOfStream from "end-of-stream";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const endOfStream = require("end-of-stream");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (16 versions; the newest 16 shown).

VersionsFormatFirst published
0.1.0 – 1.4.5CommonJSNov 26, 2013

Frequently asked

Is end-of-stream ESM-only?

end-of-stream@1.4.5 is a CommonJS package. end-of-stream ships CommonJS only. require("end-of-stream") works everywhere. import "end-of-stream" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import end-of-stream with ES module syntax?

Yes. import endOfStream from "end-of-stream" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does end-of-stream work in Bun?

Yes. import "end-of-stream" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does end-of-stream ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/end-of-stream".

Links

Other commonjs packages

Similar popularity