Npm

Npm is the Node package manager for JavaScript. It helps to discover packages of reusable code and assemble them in powerful new ways. This web development tool is a command-line utility for interacting with a said repository that aids in the package.

Features:

• Discover and reuse over 470,000 free code packages in the Registry

• Encourage code discovery and reuse within teams

• Publish and control access to namespace

• Manage public and private code using the same workflow

How to install NPM?

To install NPM you should first install Node.js. While installing node.js, NPM will install automatically.

How to check the NPM version?

To check the NPM version start DOS command prompt. Press key { START + R } and RUN window open and in RUN dialog box type CMD and press enter key.

What are the uses and advantages of NPM?

Following are the uses and advantages of NPM:

1.Manage local dependencies of project’s tools.

2.Manage globally-installed project’s tools.

3.Manage multiple versions of code and code dependencies.

4.Download standalone tools you can use right away.

5.NPM provides package-lock.json which displays all dependencies of the project.

What is PACKGE-LOCK.JSON? 

This stores file generated automatically when we request package updates (add/edit/delete).

This file displays all package details in tree format.

What is package.json?

It's a complete list of project package dependencies. You can see a screenshot of package.json which was opened in a NOTEPLUS++ application.

How to update local or global packages?

You can update local or global packages.

To update local packages:  npm update

To update global packages: npm update -g

How to uninstall a package?

You can uninstall a package with a command.

Syntax

npm uninstall <package name>

How to create package.json?

To create a new/renewed package.json file: 

Syntax

npm init

How to search available packages in NPM?

To search available packages in NPM there are the following commands:

Syntax

npm search <package name>

Aliases

As you may have noticed, there are multiple ways of running npm commands. Here is a brief list of some of the commonly used npm aliases:

npm i <package> – install local package

npm i -g </package><package> – install global package

npm un </package><package> – uninstall local package

npm up – npm update packages

npm t – run tests

npm ls – list installed modules

npm ll or npm la – print additional package information while listing modules