From the following code I can read and console.log the line
const readline = require('readline');
const { stdin: input, stdout: output } = require('process');
const rl = readline.createInterface({ input, output });
rl.question('What is your name? ', (answer) => {
console.log(`Hi ${answer}!`);
rl.close();
});
But I am trying to read user input like this
Input: node app.js John
Ouput: Hi John!
How can I achieve this in node?