Tuesday, April 16, 2019

Node.js: getting input from command line

npm i readline-sync --save

Then:

const read = require('readline-sync');

var inputstr = read.question('enter name: ');

console.log('hello ' + inputstr);

Reference:
https://teamtreehouse.com/community/how-to-get-input-in-the-console-in-nodejs

No comments:

Post a Comment