Registry / serialization / readable-stream-node-to-web

readable-stream-node-to-web

JSON →
library1.0.1jsnpmunverified

The `readable-stream-node-to-web` package offers a utility to convert a Node.js `Readable` stream into a WHATWG `ReadableStream`, commonly known as a web stream. This bridge allows developers to use Node.js stream-producing modules within web-native contexts such as Service Workers or modern browser environments, where web streams are the standard. The current and last published stable version is 1.0.1, released approximately nine years ago. Due to its age and the subsequent introduction of native stream conversion utilities directly within Node.js (e.g., `stream.Readable.toWeb()` since Node.js v17), this package is largely superseded. Its development is effectively halted, and users are encouraged to explore native Node.js APIs or more actively maintained alternatives for stream interoperability. The module was written in ES5 and was compatible with bundlers like Browserify and Webpack without needing transpilation.

npm install readable-stream-node-to-web
INSTALL
IMPORT
SIG · READABLE-STREAM-NO
R
readable-stream-node-to-web
serializationjavascriptv1.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nodeToWebStream
✓ import nodeToWebStream from 'readable-stream-node-to-web';
✗ import { nodeToWebStream } from 'readable-stream-node-to-web';
This package is a CommonJS module. While bundlers typically enable this ESM syntax via interop, the package itself is not native ESM and may behave differently in pure ESM Node.js environments.
nodeToWebStream
✓ const nodeToWebStream = require('readable-stream-node-to-web');
This is the original and intended CommonJS usage as demonstrated in the package's README.

Demonstrates converting a mock Node.js Readable stream to a WHATWG ReadableStream and then consuming its data using a web stream reader.

import { Readable } from 'node:stream'; import nodeToWebStream from 'readable-stream-node-to-web'; // Create a mock Node.js Readable stream class MockNodeReadable extends Readable { constructor(dataArray) { super(); this.data = [...dataArray]; } _read() { if (this.data.length) { this.push(this.data.shift()); } else { this.push(null); } } } const nodeStream = new MockNodeReadable(['Hello', ' ', 'World', '!']); const webStream = nodeToWebStream(nodeStream); // Consume the web stream async function consumeWebStream() { const reader = webStream.getReader(); let result = ''; while (true) { const { done, value } = await reader.read(); if (done) { break; } result += new TextDecoder().decode(value); } console.log('Consumed Web Stream:', result); } consumeWebStream();
Debug
Known issues
deprecatedThis package has not been updated in approximately nine years (last published August 2017). It is no longer actively maintained and is considered superseded.
fix
Consider using native Node.js stream conversion utilities like `stream.Readable.toWeb()` (available since Node.js v17) or `stream.Readable.fromWeb()`. Alternatively, explore more actively maintained libraries such as `node-readable-to-web-readable-stream` for robust stream interoperability.
affects: >=1.0.0
gotchaThe package is a CommonJS module. While bundlers typically handle interop, direct usage in pure ESM Node.js environments might require specific loader configurations or the `require` syntax.
fix
For native ESM environments, explicitly use dynamic `import()` or switch to a native ESM-first library that provides this functionality. If bundling, ensure your bundler is configured for CJS interop.
affects: >=1.0.0
gotchaNode.js v17 and later include built-in `stream.Readable.toWeb()` and `stream.Writable.fromWeb()` methods, offering a native and often more performant way to convert between Node.js and Web Streams. Using this package introduces an unnecessary dependency for newer Node.js versions.
fix
Upgrade to Node.js v17+ and use `import { Readable } from 'node:stream'; const webStream = nodeStream.toWeb();`. This leverages core Node.js functionality without external dependencies.
affects: <1.0.0 || >=1.0.0
Errors
Common errors & fixes
TypeError: require(...) is not a function
Attempting to use `require('readable-stream-node-to-web')` in a way that expects a named export, or in a pure ESM context without proper interop.
fix
Ensure you are using `const nodeToWebStream = require('readable-stream-node-to-web');` for CommonJS. If in an ESM file, bundlers might support `import nodeToWebStream from 'readable-stream-node-to-web';` but direct Node.js ESM might need careful handling or a switch to native APIs.
Property 'toWeb' does not exist on type 'Readable'
Attempting to use `nodeStream.toWeb()` on a Node.js `Readable` stream in an older Node.js version (<v17) or without TypeScript type declarations for `toWeb`.
fix
Ensure Node.js is v17 or newer for native `.toWeb()` support. If using an older Node.js, you must use this `readable-stream-node-to-web` package (or a similar alternative) for conversion. For TypeScript, ensure your `tsconfig.json` targets a Node.js version that includes these types or add a custom declaration file.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
readable-stream-node-to-web — npm install readable-stream-node-to-web · libregistry