What is NPM

NPM stands for node package manager.

Node.js follows the philosophy of small modules.

Module:- It is a reusable piece of code that handles a single functionality. Here single functionality does not mean some lines of code.

There could be more than one module in node.js To manage multiple modules we have a package manager with us NPM & Yarn

These are module manager or package manager.

Let's suppose we want to use the M2 Module or M3 Module. But these modules depend on the M1 Module before using the M2 module or M3 module we have to install the M1 Module because we need the M1 module. This above graph is called a dependency graph.

Let's suppose we want to use the X (random) module. To use this X module what other dependent modules do we need, what should be the order of installation, and what should be the version of these modules? All of these are handled by the package manager (NPM or Yarn).

Suppose the M2 module and M3 module depend on the M1 module. But M2 depends on the M1 module of version x and M2 depends on the M1 module of version y which creates conflicts. These types of conflicts are handled by npm automatically you don't need to bother a lot.