我只想简单地从键盘上读取文本并将其存储到变量中.因此对于:
var color = 'blue'
我希望用户从键盘提供颜色输入.谢谢!
解决方法:
如果您不需要异步,我建议使用readline-sync模块.
# npm install readline-sync
const readline = require('readline-sync');
let name = readline.question("What is your name?");
console.log("Hi " + name + ", nice to meet you.");