Npm is a software registry, which holds hundreds of thousands libraries. It is used in a JavaScript based project to install dependencies.
The dependencies are added using npm, which install the dependencies in a transitive manner. This means that in case we install library A, which requires library B, and library B requires library C, then A, B, and C are all installed.
Not only that but npm also manages the versions requirements, so if A requires a specific version of B. Unlike other tools (like maven) npm can install different versions o the same library. See a nice example in the post: Understanding npm dependency resolution.
Still, there are some keynotes of npm usage for an npm user to keep in mind.
First, always install dependencies using install flag, e.g.:
npm install my-dependency-library
This does the following:
- Adds the recent version of the library to the package.json file.
- Add all the transitive dependencies of the library to the package-lock.json file.
- Install (downloads) all the transitive dependencies to the node_modules folder.
No comments:
Post a Comment