Yargs module is used for creating your own command-line commands in node.js and helps in generating an elegant user interface. This module makes command-line arguments flexible and easy to use.
Installation of yargs module:
- You can visit the link Install yargs module. You can install this package by using this command.
npm install yargs
- After installing yargs you can check your yargs version in command prompt using the command.
npm version yargs
- After that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.
Steps to run the program:
- The project structure will look like this:
- Make sure you have install express and yargs module using following commands:
npm install express npm install yargs
- Run index.js file using below command:
After running this above command, now yargs command is set, you can use it as shown below:
node index.js add --firstNumber=4 --secondNumber=10
So this is how you can use yargs module for making your own command-line arguments command thereby making it more interactive.
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs - Connect MongoDB with Node app using MongooseJS
- Cowsay in Nodejs using Requests library
- Nodejs | Web Crawling using Cheerio
- Web-Socket in NodeJS
- Signup Form Using Nodejs and MongoDB
- Dockerizing a simple Nodejs app
- Nodejs | DNS
- Encrypting Data in NodeJS
- Difference between NodeJS and AngularJS
- Nodejs | Jimp
- Nodejs – Connect Mysql with Node app
- Nodejs | DNS | setServers()
- NodeJS | Building simple REST API in express
- NodeJs - Handling invalid routes
- Nodejs | authentication using Passportjs and passport-local-mongoose
- Nodejs | GM charcoal() Function
- Nodejs | GM blur() Function
- Nodejs | GM sharpen() Function
- Nodejs | GM drawLine() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.