NPM in Node Js

NPM stands for Node Package Manager. It is used to install various libraries in our project. NPM is a default package manager for Node Js. It has basically two parts:

  1. A code repository, where all the code is hosted.
  2. A command line interface, for downloading the libraries from the online repository.

Installing packages using NPM

The –save flag will add express in the production dependencies.
The –save-dev flag will add express in development dependencies.

What is package.json file?

package.json file is created when we run the npm init command. This file contains all the details of our project like name, version, author, dependencies, description, scripts, license etc.

It is the file which is used by NPM to download the node modules required by your project with the proper version.

What is package-lock.json file?

The contents of the package.json file can be changed, for example if we have updated our packages, then the package.json will contain the latest updates. But the package-lock.json file contains the exact dependencies.

Leave a Reply

Your email address will not be published. Required fields are marked *