Code:
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
function input(str) {
return new Promise(res => {
readline.question(str, result => {
res(result);
});
})
}
async function start() {
const username = await input('Enter username: ');
console.log(`Hello ${username}`);
readline.close();
}
start()
Run:
node [file_name]