How to use NodeJs Module using Command Line Interface (CLI)?
In this code snippet, we will discuss how we can use Nodejs module using npm cli (Command line interface). We will discuss bit about CLI. Firstly, we will get the nodejs module and then start using it.
Introduction In this code snippet, we will discuss how we can use Nodejs module using npm cli (Command line interface). First fo all lets us discuss what is CLI? Lets directly talk about our NodeJs module. In our current code-snippet we are not going to develop any new Nodejs module, although we will use an existing one. Detailing for NPM CLI, Nodejs is beyond the scope. Follow these steps to get existing Nodejs modules Please note that if you do not have Nodejs installed on your system, you need to install one. Now you're ready to use the package. Use following code snippet: Initiate node: Create object: Use public methods/functions: Check the output: All thats it, we've done with it :) In this code-snippet, we discussed how to use existing Nodejs modules using npm CLI.
What is CLI?
So, CLI is nothing but Command Line Inteface. An inteface for user to interact either with Operating System or directly with associated application.
Here, we will use npm cli in our code snippet.
Talking about code
Write following and hit enter:npm install number2text
ORnpm install number2text --save
node
var numberToText = require('number2text');
var textDefault = numberToText(100);console.log('Converts 1000000 to ', textDefault);
Conclusion