Introduction to npm
npm·2 min read·Jan 1, 2025
npm, short for Node Package Manager, is the default package manager for Node.js that comes pre-installed with every distribution.
It is used to:
- Download and use packages for your Node.js applications.
- Download and use standalone command-line interface tools.
- Coordinate package maintenance across your organization.
- Share code with other developers around the world.
- Find other developers who are working on similar problems.
The npm ecosystem consists of three distinct components:
- The website: accessible at www.npmjs.com, it provides a simple interface for you to browse through the available JavaScript and Node.js packages, and manage your personal or organization account information.
- The registry: a large online database containing millions of both public (i.e. open-source) and private packages that developers can download, install, and use in their own Node.js applications and projects.
- The command-line tool: a utility that allows you to manage packages both on your local machine and on the npm registry, and also to automate common tasks such as running tests, building projects, or deploying to multiple environments.
Learning objectives
After completing this module, you will be able to:
- Initialize and configure Node.js projects using
npm. - Install and use third-party packages in your applications.
- Run packages as CLI tools, locally and globally.
- Inspect your dependency tree and understand what is installed and why.
- Update packages safely and lock versions to reduce breaking changes.
- Remove packages cleanly and keep your project dependencies under control.
- Automate common development tasks using npm scripts.
- Publish a package to the npm registry and document it with a proper README.