I\'ve been doing this to synchronously read the whole stdin data under Linux:
var buffer = fs.readFileSync(\'/dev/stdin\');
This obviously
The module readline-sync do the job very well.
npm install readline-sync
and then:
var readlineSync = require('readline-sync');
var answer = readlineSync.question('What is your favorite food? :');
console.log('Oh, so your favorite food is ' + answer);
https://www.npmjs.com/package/readline-sync
var size = fs.fstatSync(process.stdin.fd).size;
var buffer = size > 0 ? fs.readSync(process.stdin.fd, size)[0] : '';