javascript – Node js Console
try to use readline module in node.js, it provides an interface for reading the data from readable stream.
to create a readline interface, use the createInterface method, specifying (proccess.stdin) as the input stream (where user input will be read from) and (process.stdout) as the output stream (where the output will be written).
note: proccess is a global object in Node.js. It provides information about, and control over, the current Node.js process. It’s part of the Node.js runtime environment and is available globally in all modules.
here is an example:
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter something: ', (userInput) => {
console.log(`You entered: ${userInput}`);
rl.close();
});
Read more here: Source link