I am new to Node.js and I do not understand how the readline module works. Here is my code block:
const { stdout } = require("process");
const {stdin} = require("process");
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
readline.question(`What's your funny name?`, name => {
console.log(`Hi ${name}!`);
readline.close();
});
Note that this block of code comes from this location on SO: Node.js "readline" not working as intended
I am expecting that the call to readline.question will pause and wait for the user to respond but this does not happen. The program continues on without pausing for input.
I have also tried
process.stdin.read()
process.stdin.on("data", (data) => {
myAnswers.push(data);
askQuestions(questionNumber+1);
})
Again, the code does not pause to allow the user to input some text.
Any assistance would be appreciated.