npm Introduction

Terminology

Package Management System
Software that automates installing and updating packages/libraries/frameworks, including their dependencies.
npm
npm Package Manager, previously Node package manager (npm is now used for many software projects besides Node).
npm package
A package is a file or directory that is described by a package.json file.
Dependency
Code that your app needs to function properly. Each dependency will most likely have their own list of dependencies, which npm also manages.
Development dependency
An npm package that's only needed during development (i.e. nodemon to help reload new code). These dependencies should be ignored when the app is in production.
Global npm package
A package that is installed globally on your machine so that it's available to every npm project. Global packages will not show up in your node_modules directory.
Semantic versioning
A three number versioning system (major.minor.patch => 2.3.1) for software. See Semantic Versioning using npm.

Why do we use npm?

  1. Dependency management: any npm package you install into your project becomes a dependency. Chances are, that package comes with its own set of dependencies, and so on. npm manages these interactions.
  2. Development and deployment: npm includes many tools that help developers create and deploy software projects.
  3. Project collaboration: npm ensures that multiple developers can reliably replicate a software project in their development environments.

Stats and trivia

npm is the largest software package registry in the world. According to the npm Wikipedia page and this Linux.com article

Example npm directory structure

my-project-root
├── node_modules
│   └── dependency-1
│   ├── dependency-2
    └── dependency-3
└── app.js
├── package-lock.json
└── package.json

Key Takeaways

Related resources