Lets get user inputs using inquirer and Yargs — Creating a npm command line Utility — Part 2

Praveen David Mathew
5 min readFeb 16, 2022

now lets see how we can get user inputs to over commandline uility


We have seen how to create a simple command line utility that prints “Hello User!”. Now we will see how we can accept user inputs and print the input instead of the hardcoded value

Please Read: https://praveendavidmathew.medium.com/narrative-story-on-how-to-create-command-line-utility-project-part-1-164ce056eb90

This is continuation of previous article

Lets get started:


CJS setup:

First lets see how to do this in cjs (plain javascript)

Currently we have the below project structure from the previous article

Now we have to get user input for replacing the hardcoded name, this can be done by using yargs (non interactive) or inquirer (interactive) . You can directly use process.argv but it is not a clean way to do it as it wont sanitize the user inputs.

Yargs setup:

install yargs : npm install yargs --save

Now update the index.js file as :

#! /usr/bin/env node



Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker