Understanding npm dependency resolution

Bhammarker Rahul
Learn With Rahul
Published in
5 min readSep 24, 2017

--

In the front-end world everything is being used as a package and delivered in terms of packages. Packages depend on other packages and they express those dependencies in a specific type of notation called semantic versioning. So to manage these there are a strong need of an efficient package management system and there are many available like bower, yarn and npm. Among all the npm seems to won the competition we wont go into much detail why but its really efficient checkout this article for more details.

npm reads package.json file (which usually placed at the root directory) to install the dependencies and installed then under sub directory named “node_modules”. npm understand the semver syntax for the required version of the depended packages. Now these packages will be used by the source code and lies in the same context but how these are made available and how its been managed by the npm if multiple package depends on the same package or multiple package required the same package but different versions in both cases redundancy and packages size is the main concerns which should be considered while resolving these dependency and here the npm flourish its magic.

To install the packages “npm install” is the command that is used, it searches for the package.json and prepares a tree as per the dependencies mentioned in it and the dependencies of…

--

--