Node Package Manager And Node.js







Node Package Manager
Node Package Manager (NPM) is a default package manager for Node.js. NPM is included with Node.js installation. That tool allows to installs, updates or uninstalls Node.js packages in your application. It is also an online repository. NPM performs the operation in two modes which is global and local. Globe type affect all the Node.js applications on the computer where as in the local mode. Local type affect an application that directory only.

After installed Node.js, version of NPM can be checked by writing the following command.
npm -v

If the installed version is not the latest, you can update it using the below command.
npm npm@latest -g.

If any help needed it will provide by using the npm help command.
npm help

Following command can be used to install packages and modules in the project.
npm install package_name

Example
npm install express

Below command can be used to import the express framework.
var express = require(‘express’);

Uninstallation of the packages can be done by the following command. 
npm uninstall

Uninstallation of the global packages can be done by the following command. 
npm uninstall package_name -g
  
By adding –save at the end of the install command will add dependency entry in
to the package.js of the application.
npm install express -–save

The following command will install ExpressJS globally in the application and also adds dependency entry into the package.json.
npm install -g express

The following code segment shows package.json of Nodejs ConsoleApp.
package.json
{
  "name": "NodejsConsoleApp",
  "version": "0.0.0",
  "description": "NodejsConsoleApp",
  "main": "app.js",
  "author": {
  "name": "Dev",
  "email": ""
  },
  "dependencies": {
    "express": "^4.13.3"
  }
}


Advantages of Node
  • Makes building real-time apps faster.
  • Makes coding in JavaScript and use one single programming language to write both client and server side.
  • Increases the efficiency of the development process. 
  • Gives developers multiple tools and modules to use thus further boosting their productivity.  
  • Code executes faster than other programming languages. 
  • It may run on any cross platform such as Linux, Window or Mac.



Comments