Registry / http-networking / stdin
library2020.12.3jsnpmunverified

This package provides a minimal, callback-based utility for reading standard input in Node.js environments. Published in 2012 and last updated around that time (version 0.0.1), it addresses the common pain point of handling `stdin` streams in Node.js, which was less streamlined in older versions. It offers a single function that consumes the entire standard input as a string and provides it to a callback. Given its age and the significant evolution of Node.js with better-supported stream APIs (like `process.stdin` directly, `readline` module, or `async` iterators), this package is largely obsolete. Its release cadence was minimal, likely a one-off utility. At the time of its release, its key differentiator was its simplicity over raw stream handling. However, it lacks modern features like Promises, async/await, or TypeScript support.

npm install stdin
INSTALL
IMPORT
SIG · STDIN
S
stdin
http-networkingjavascriptv2020.12.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

stdin
const stdin = require('stdin');
import stdin from 'stdin';
This package is exclusively CommonJS. It does not support ES module `import` syntax.

Demonstrates how to use the `stdin` package to read a complete string from standard input and process it using a callback function. Users must manually signal end-of-file (EOF).

const stdin = require('stdin'); console.log("Please type something and press Enter, then signal EOF (Ctrl+D on Unix/macOS, Ctrl+Z then Enter on Windows):"); stdin(function(inputString) { if (inputString && inputString.trim().length > 0) { console.log("You entered:", inputString.trim()); } else { console.log("No input received from stdin."); } process.exit(0); }); // Add a timeout in case no input is provided, to prevent the process from hanging indefinitely // In a real application, you might use an explicit `process.stdin.on('end')` or `process.exit()` // based on application logic, but for a quickstart, a timeout can prevent indefinite waits. // For interactive use, user must signal EOF (Ctrl+D / Ctrl+Z). setTimeout(() => { if (!process.stdin.isTTY) { // If stdin is not a TTY (e.g., piped input), the `stdin` package should handle `end` automatically. // This timeout is primarily for interactive sessions where EOF might not be sent. } }, 5000).unref(); // unref allows the program to exit if other work is done
Debug
Known issues
deprecatedThis package is extremely old (last update ~2012, v0.0.1) and appears to be completely abandoned. Modern Node.js offers robust built-in ways to handle standard input (e.g., `process.stdin` with stream events, `readline` module, `for await...of process.stdin` in newer Node versions), making this package largely redundant and potentially less performant or feature-rich than native options.
fix
Migrate to native Node.js `process.stdin` stream handling, the `readline` module, or modern npm packages that leverage these APIs with updated patterns (e.g., Promises).
affects: *
gotchaThe `stdin` package uses a callback-based API, typical of Node.js patterns from its era. It does not natively support Promises, async/await, or TypeScript type definitions, which are standard in modern JavaScript development.
fix
If you require Promise-based or async/await syntax, you would need to manually wrap the `stdin` call in a `new Promise()` or use a different, more modern library that provides these features out-of-the-box.
affects: *
breakingRunning unmaintained code from 2012 can pose compatibility challenges with newer Node.js versions and environments. More critically, unmaintained packages do not receive security updates, potentially leaving applications vulnerable to discovered exploits that could affect standard input processing or general application stability.
fix
Thoroughly audit the source code for vulnerabilities and compatibility issues, or, preferably, migrate to an actively maintained solution to ensure long-term stability and security.
affects: *
Errors
Common errors & fixes
ReferenceError: reqiure is not defined
The example code in the README contains a typo, using `reqiure` instead of `require`.
fix
Correct the typo to `const stdin = require('stdin');`
SyntaxError: Cannot use import statement outside a module OR ERR_REQUIRE_ESM
Attempting to use ES module `import` syntax (`import stdin from 'stdin';`) with this package, which is exclusively CommonJS.
fix
Use the CommonJS `require()` syntax: `const stdin = require('stdin');`. Ensure your project's module system is configured correctly for CommonJS if using older Node.js versions or mixed environments.
Node.js process hangs indefinitely OR Program exits without reading stdin
The program might exit prematurely if input is not provided quickly enough or if the standard input stream's end-of-file (EOF) signal is not sent. Conversely, it can hang waiting for input in interactive sessions if EOF is never signaled.
fix
For interactive use, ensure that the standard input stream is properly closed after providing input (e.g., via Ctrl+D on Unix-like systems, Ctrl+Z then Enter on Windows). For programmatic input, pipe data to the script (e.g., `echo "hello" | node myscript.js`). Ensure your application logic handles the `stdin` stream's `end` event or uses timeouts as appropriate.
Upgrade
Version history
2020.12.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
stdin — npm install stdin · libregistry