I would just like something simple to read text from a keyboard and store it into a variable. So for:
var color = \'blue\'
I would like the
We can also use NodeJS core standard input functionality for the same.
ctrl+D
for end standard input data reading.
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var input_data = "";
process.stdin.on("data", function(input) {
input_data += input; // Reading input from STDIN
if (input === "exit\n") {
process.exit();
}
});
process.stdin.on("end", function() {
main(input_data);
});
function main(input) {
process.stdout.write(input);
}