This article has a good summary

The basic:

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

readline.question('Who are you?', name => {
  console.log(`Hey there ${name}!`);
  readline.close();
});

Using prompt-sync package

After npm install prompt-sync

const prompt = require('prompt-sync')();

const name = prompt('What is your name?');
console.log(`Hey there ${name}`);

Working with Numbers

All user input will be read as a String, so in order to treat user input as numbers, you’ll need to convert the input:

const num = prompt('Enter a number: ');
console.log('Your number + 4 =');
console.log(Number(num) + 4); // or use parseInt()