我一直这样做是为了在
Linux下同步读取整个stdin数据:
var buffer = fs.readFileSync('/dev/stdin');
这显然不适用于Windows,因为没有/ dev / stdin文件.我能做些什么来实现同样的目标?
解决方法
模块readline-sync可以很好地完成工作.
npm install readline-sync
然后:
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