`tty-browserify` provides a browser-compatible stub for the Node.js core `tty` module, enabling Node.js applications that use `require('tty')` to be bundled and run in a browser environment via Browserify. It primarily offers a `tty.isatty()` function which consistently returns `false` in the browser context, as true TTY (teletypewriter) devices do not exist in standard web browsers. Attempts to instantiate `tty.ReadStream` or `tty.WriteStream` directly in the browser will result in errors, reflecting the fundamental difference in I/O environments between Node.js CLI applications and web browsers. This package, currently at version 0.0.1, has not seen active development since its last release over eight years ago (January 2018) but remains a crucial underlying dependency for many legacy Browserify-based projects, evident by its high weekly download count despite its age. Its release cadence is effectively dormant, and its key differentiator is its role as a direct translation layer for a core Node.js API to the browser via Browserify's module resolution.
npm install tty-browserifyVerified import paths — ran on the pinned version, not inferred.
Demonstrates the core stubbed functionality of `tty-browserify`: `isatty` returning `false` and `ReadStream`/`WriteStream` throwing errors in a browser context. This code needs to be bundled with Browserify to run in a browser.
Avoid using `new tty.ReadStream()` or `new tty.WriteStream()`. If Node.js `tty` streams are required, the application cannot run directly in a browser without significant architectural changes.
Design browser-compatible code paths that do not rely on TTY functionality, or explicitly handle the `false` return from `tty.isatty()`.
Evaluate whether your project still requires Browserify and its core module shims. For new projects, consider modern bundlers (e.g., Webpack, Rollup, Vite) which might offer more flexible or explicit polyfill strategies, or refactor to avoid Node.js-specific modules in browser code.
Remove or conditionally guard calls to `new tty.ReadStream()`. Refactor code to use browser-native input mechanisms if interactive input is needed.
Remove or conditionally guard calls to `new tty.WriteStream()`. Refactor code to use browser-native output mechanisms (e.g., `console.log`, DOM manipulation) instead.
Ensure your script is processed by Browserify (or another CommonJS-compatible bundler) and included correctly in your HTML. Use `browserify your_script.js -o bundle.js` and link `<script src="bundle.js"></script>`.
No dependency data recorded yet.