# npm

> The tool for getting JavaScript packages. It is also the big shelf they come from.

**Field:** Software Development  
**Category:** Editors & Tools  
**Also known as:** Node Package Manager, npm registry

## Think of it like

Think of it like the biggest toy shop in the world. Almost any part you want for a JavaScript app is on a shelf there.

## Definition

npm is the package tool for JavaScript, and it comes with Node.js. It is also the name of the online registry where JavaScript packages are shared. It holds millions of packages, more than any other registry. The npm install command fetches packages. A file named package.json lists what a project needs. npm can also run a project's scripts, like npm test.

## Example

Jack runs npm install in a new React project. A folder fills up with each package the app needs.

## Example code

```console
$ npm install lodash

added 1 package, and audited 2 packages in 668ms
```

npm fetches lodash and adds it to package.json.

## Why it matters

Most JavaScript projects are set up and run through npm. That goes for the browser and the server.

## Common mistake

Saving the node_modules folder in Git. It is huge, and one npm install builds it again.

## Three principles

- **Comes with Node.** Install Node.js and you have npm.
- **A huge registry.** Millions of packages to choose from.
- **Runs scripts too.** npm test and npm run build start tasks.

## Related terms

- [Package Manager](https://learn.benibix.com/term/development/package-manager)
- [pip](https://learn.benibix.com/term/development/pip)
- [JavaScript](https://learn.benibix.com/term/development/javascript)
- [Dependency](https://learn.benibix.com/term/development/dependency)
- [Package Registry](https://learn.benibix.com/term/development/package-registry)
- [package.json](https://learn.benibix.com/term/development/package-json)
- [Yarn](https://learn.benibix.com/term/development/yarn)

## Told apart from

- [npm vs Yarn](https://learn.benibix.com/compare/npm-vs-yarn): People think Yarn has its own store of packages, apart from npm, and it does not. Yarn and npm both fetch from the same npm registry. They differ in how they install, and in the lockfile they write. npm writes package-lock.json, and Yarn writes yarn.lock. A project should pick one and stick to it.
- [npm vs pnpm](https://learn.benibix.com/compare/npm-vs-pnpm): People think pnpm is just a faster npm, and there is more to it. npm puts a full copy of each package in every project. pnpm keeps one copy of each version on the disk and links each project to it. pnpm is also strict, so code may only use the packages it listed.

## Taught in

- [Package Managers, npm and pip](https://learn.benibix.com/learn/development-tools/package-managers-npm-and-pip): Coding Tools, 8/13

---

Source: https://learn.benibix.com/term/development/npm
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
