# Package Managers, npm and pip

> What a package is, where it lives, and how a package manager fetches it. How npm does it for JavaScript and pip for Python.

**Course:** [Code Editors and Package Managers](https://learn.benibix.com/learn/development-tools)  
**Time:** 12 min

**After this lesson you can:**

- Say what a package and a registry are
- Install a package with npm or pip
- Check a package before you trust it

## How a package gets from the shelf into your project

A package is shared code with a name and a version number. A package registry is the website that stores packages, and Python's main one alone holds more than 900,000 projects. A package manager is the tool that fetches them. You type one command with a name, and it downloads that package and each package it needs.

Most packages hold a library, and some hold a tool you run. Each one also carries a list of the other packages it needs. That list is why one install can bring in fifty packages: each one asks for its own.

Each language has its main registry. JavaScript has the npm registry, which holds millions of packages. Python has the Python Package Index, called PyPI for short. Big firms also run their own private ones for their own code.

npm is the package manager for JavaScript, and it comes with Node.js. Type npm install and a name, and it fetches that package from the npm registry. A file in the project lists what it needs. So a teammate can type npm install and get the same set.

pip is the standard package manager for Python, and it comes with Python. The command pip install and a name fetches a package from PyPI. Like npm, it brings in whatever that package needs. Python projects keep their own list of needed packages, so anyone can install the same set.

A package manager also writes down exactly what it installed. That record, the lockfile, is what lets a second computer get the same versions. It belongs in Git with the rest of your code.

Anyone can put a package on a public registry, and that is the danger. Some people post fake packages with names one letter off from real ones. They hope you make a typo. Check the spelling, the author and how many people use a package before you install it.

```console
$ npm install lodash

added 1 package, and audited 2 packages in 668ms

found 0 vulnerabilities
$ pip install requests
Successfully installed certifi-2026.10.23 charset_normalizer-3.5.2 idna-3.20 requests-2.34.2 urllib3-2.8.0
```
npm fetches one package. pip fetches one, plus the four it needs, which is why five names come back.

![A package registry, drawn as a big shelf of named boxes, on the left. An arrow marked install runs to a package manager in the middle. It writes two things into the project on the right: the packages themselves, and a lockfile that lists the exact version of each one, such as left-pad 1.3.0. A second computer reads the same lockfile and gets the same versions.](https://learn.benibix.com/diagrams/dev-package-flow.svg)

### Example: Jack almost installs the wrong package

Jack types pip install reqeusts, with two letters swapped. He stops before pressing Enter and looks the name up on PyPI.

The real requests package is used by millions of projects. The misspelled name has no known author, so he types the real one.

**Words in this lesson:** [Software Package](https://learn.benibix.com/term/development/software-package), [Package Registry](https://learn.benibix.com/term/development/package-registry), [Package Manager](https://learn.benibix.com/term/development/package-manager), [npm](https://learn.benibix.com/term/development/npm), [pip](https://learn.benibix.com/term/development/pip)

**Question:** Is a package safe because it is on npm or PyPI?

**Answer:** No, anyone can publish, so check the name and the author. Anyone can post to a public registry. Fake packages use names one letter off from real ones. So read the spelling, the author and how many people use it.

---

Source: https://learn.benibix.com/learn/development-tools/package-managers-npm-and-pip
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-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
