


Magically, all the dependencies of the tree will be downloaded and installed. If someone wants to add your library to their project, then they will just need to run: $ npm install When you create an npm library you will create a json file called package.json in which you specify which dependencies your JS library has.Īt the same time, the dependencies of your library will have their own package.json files, creating a full dependency tree. That’s exactly the problem that npm solves. A simple update in a submodule might break your dependency tree and your app might not compile.

This situation would be a nightmare to manage manually. And what’s even worse, each of those dependencies will only be compatible with certain specific versions. Sooner or later your project will end up with dozens of dependencies (you won’t even be aware of some of them). That’s called the dependency tree of your application. Imagine that, at the same time, library C uses another five different libraries to handle different languages and you end up with a scheme like this one. That library uses library B to format text and library C to show translations. Imagine that you include library A to customize a text field. It is built on top of Node and is so powerful that nearly everybody is using it. Node Package Manager, or npm (usually written in lower case) is one of the most commonly used package managers in JavaScript projects.
