stream-browserify is a module that provides the Node.js `stream` API for browser environments. It serves as a polyfill, allowing npm packages designed for Node.js streams to function correctly within a browser context when bundled. The current stable version is 3.0.0, released after a period of using `readable-stream` v2, and now fully leverages `readable-stream` v3. This package is primarily intended for use with bundlers like Browserify, which automatically substitute the native Node.js `stream` module with `stream-browserify` during the bundling process. Its key differentiator is providing a consistent, spec-compliant stream implementation that bridges the gap between Node.js module expectations and browser limitations, ensuring broad compatibility for legacy and modern stream APIs in the browser.
npm install stream-browserifyVerified import paths — ran on the pinned version, not inferred.
Demonstrates creating and piping a basic readable stream to a writable stream using `stream-browserify`.
Review the `readable-stream` v3 documentation for breaking changes (e.g., changes to `_read` behavior, error handling, `pipeline`, and `finished` utilities). Adapt stream implementations and consumption patterns accordingly.
If using Browserify, avoid explicit `npm install stream-browserify` unless a specific version conflict or direct module access is required. Rely on the bundler's resolution.
Use `npm ls readable-stream` or `yarn why readable-stream` to inspect your dependency tree. Resolve any duplicate or conflicting `readable-stream` versions to ensure a consistent stream implementation across your project. Consider `resolutions` or `overrides` if necessary.
Ensure your project is bundled with a tool like Browserify that provides `stream-browserify` as a shim for `require('stream')`. If directly importing, use `import { Readable } from 'stream-browserify';`. Verify bundler configuration.If using Browserify, ensure `stream-browserify` is correctly integrated by the bundler. If not using a bundler or needing a global stream polyfill, you might need to manually configure aliasing or ensure `stream-browserify` is included in your build process.