How To Get Input from the Terminal in Node.js

In this video, we will learn How To Get Input from the Terminal in Node.js .

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

reader.question("Please enter your name : ", name => {
    console.log(`Hello ${name}`);
    reader.close();
});

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *