After my first tutorials which is How to create server in node js i want to explain what is node package manager. Because after this tutorials we gonna look in how's node module works. So let's start with what is node package manager.
Node package manager is online repositories for node.js packages/modules. To install node package and do version management we have to use commands.
To check current NPM version on your computer type below command
If you running old version than you can update easily by running below commnand
Node package manager is online repositories for node.js packages/modules. To install node package and do version management we have to use commands.
To check current NPM version on your computer type below command
$ npm --version
If you running old version than you can update easily by running below commnand
$ sudo npm install npm -g
How to install module using npm
Using below command you can install module in node$ npm installSuppose you want to install express module of node then you have to type below command.
$ npm install express
Global vs local module installation
By default npm install local module to use local module you can use require method. To check which module is install locally you use below command$ npm lsTo install global module you can use below command.
$ npm installYou can use the following command to check all the modules installed globally-g
$ npm ls -g
Package.Json file
by typing below command you can generate package.json file$ npm initIf you want to save you locally module in package.json file you can type below command
$ npm install --save expressAbove command will save your module name and installed version in package.json file
Uninstall module
Use the following command to uninstall a Node.js module.$ npm uninstall express
Updating a Module
Update package.json and change the version of the dependency to be updated and run the following command.$ npm update express
Search a Module
Search a package name using NPM.$ npm search express
Please comment down below if you have any query and please follows us for more awesome tutorials and keep motivating us .
0 comments:
Post a Comment