{"id":22544,"library":"vite-compatible-readable-stream","title":"Vite-Compatible Readable Stream","description":"A fork of readable-stream (v3.6.1) modified to remove circular dependencies, ensuring compatibility with Rollup and Vite production builds. It provides Node.js stream primitives (Readable, Writable, Transform, Duplex, PassThrough) in browser environments. Unlike the original readable-stream, this version eliminates circular require/import chains that cause Vite to fail during tree-shaking or bundling. It is primarily intended as a shim for libraries like react-pdf that depend on Node.js streams in browser contexts.","status":"active","version":"3.6.1","language":"javascript","source_language":"en","source_url":"git://github.com/TechInSite/readable-stream","tags":["javascript","readable","stream","pipe"],"install":[{"cmd":"npm install vite-compatible-readable-stream","lang":"bash","label":"npm"},{"cmd":"yarn add vite-compatible-readable-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-compatible-readable-stream","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"upstream source of stream implementation","package":"readable-stream","optional":false}],"imports":[{"note":"ESM import is preferred; named exports available for Readable, Writable, Transform, Duplex, PassThrough, pipeline, finished, destroy","wrong":"const Readable = require('vite-compatible-readable-stream').Readable","symbol":"Readable","correct":"import { Readable } from 'vite-compatible-readable-stream'"},{"note":"Default export is the Readable class; other classes are named exports.","wrong":"import Writable from 'vite-compatible-readable-stream'","symbol":"Writable","correct":"import { Writable } from 'vite-compatible-readable-stream'"},{"note":"Use this package instead of readable-stream to avoid Vite build errors.","wrong":"import { pipeline } from 'readable-stream'","symbol":"pipeline","correct":"import { pipeline } from 'vite-compatible-readable-stream'"},{"note":"No default 'Stream' export; use specific classes.","wrong":"import Stream from 'vite-compatible-readable-stream'","symbol":"Stream","correct":"import { Readable, Writable, Transform, Duplex, PassThrough } from 'vite-compatible-readable-stream'"}],"quickstart":{"code":"import { Readable } from 'vite-compatible-readable-stream';\n\n// Create a readable stream that emits numbers 1 to 5\nconst numbersStream = new Readable({\n  objectMode: true,\n  read() {\n    if (this.current === undefined) this.current = 1;\n    if (this.current <= 5) {\n      this.push(this.current++);\n    } else {\n      this.push(null);\n    }\n  }\n});\n\n// Consume the stream\nnumbersStream.on('data', (chunk) => console.log(chunk));\nnumbersStream.on('end', () => console.log('Stream ended.'));\n\n// Output:\n// 1\n// 2\n// 3\n// 4\n// 5\n// Stream ended.","lang":"javascript","description":"Creates and consumes a simple readable stream emitting numbers 1 to 5."},"warnings":[{"fix":"Upgrade to v3.6.1 or ensure Node.js >= 6.","message":"vite-compatible-readable-stream v3.6.1 may not be compatible with Node.js versions below 6.","severity":"breaking","affected_versions":"<3.6.1"},{"fix":"Test thoroughly if migrating from readable-stream to this fork.","message":"This package removes circular dependencies from readable-stream, but it may not behave identically to the original readable-stream in edge cases.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Change `import Stream from 'vite-compatible-readable-stream'` to `import { Readable } from 'vite-compatible-readable-stream'`.","message":"Default export is the Readable class, not a stream factory. Use named exports for other stream types.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace all imports from 'readable-stream' with 'vite-compatible-readable-stream'.","message":"Do not use the original 'readable-stream' package in Vite builds to avoid 'Module parse failed: Unexpected token' errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Monitor upstream readable-stream releases and consider alternatives if features are missing.","message":"The package's repository is a fork of readable-stream; future updates may lag behind upstream.","severity":"deprecated","affected_versions":">=3.6.1"},{"fix":"Use conditional imports or detect environment to switch between native stream and this polyfill.","message":"This package is intended for browser/Vite usage; in Node.js environments, prefer the native 'stream' module.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Replace 'readable-stream' with 'vite-compatible-readable-stream' in package.json and imports.","cause":"Using the original 'readable-stream' package in a Vite build without proper transpilation.","error":"Module parse failed: Unexpected token (1:44) at ... You may need an appropriate loader to handle this file type."},{"fix":"Ensure you are using correct class: Readable for readable streams, Writable for writable streams.","cause":"Using the wrong stream class (e.g., Writable when you need Writeable).","error":"Uncaught TypeError: stream.push is not a function"},{"fix":"Run `npm install vite-compatible-readable-stream` or add to package.json dependencies.","cause":"Package not installed or not found in node_modules.","error":"Cannot find module 'vite-compatible-readable-stream'"},{"fix":"Import specific classes: `import { Readable, Writable, Transform, Duplex, PassThrough } from 'vite-compatible-readable-stream'`.","cause":"Importing a default 'Stream' export which does not exist.","error":"The requested module 'vite-compatible-readable-stream' does not provide an export named 'Stream'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}