# Yarn, pnpm, Cargo and Homebrew

> The other package managers you will meet. Yarn and pnpm in place of npm, Cargo for Rust, and Homebrew for apps on a Mac or Linux.

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

**After this lesson you can:**

- Say why a team picks Yarn or pnpm
- Build a Rust project with Cargo
- Install a tool with Homebrew

## Which package manager does what

npm and pip are not the only package managers. Yarn, out since 2016, and pnpm do npm's job in their own way, and both fetch from the same npm registry. Cargo is the package manager for Rust. Homebrew, from 2009, installs whole apps and tools on macOS and Linux.

Yarn came early with ideas like a lockfile and fast installs that work offline. You add a package with yarn add, and it writes a lockfile called yarn.lock. Teams pick it for speed, and for its tools for big projects made of many parts.

pnpm saves disk space. It keeps each version of a package only once, in one store on your computer, and each project links to those files instead of copying them. Ten projects that use the same package share one copy. It is also strict: your code can only use packages it listed.

Cargo is the package manager and build tool for Rust, in one. It downloads the packages your project needs, which Rust calls crates, from crates.io. It also builds your code, runs it and tests it. The list of crates lives in a file called Cargo.toml.

Homebrew is a little different. It installs apps and command-line tools, not the parts of one project. One command, brew install and a name, fetches a tool and sets it up. Many developers use it to fill a new Mac with Git, Python and the rest in an afternoon.

Do not run Homebrew with admin rights. It is built to run as your own user, and admin rights can leave its folders owned by the wrong account. Run brew upgrade from time to time to update everything it installed at once.

The common mistake is mixing two package managers in one project. npm and Yarn each write their own lockfile. Over time the two drift apart, and teammates get different versions. Pick one, and delete the other one's lockfile.

## Package managers and where they fetch from

| Tool | For | Fetches from | Lockfile |
| --- | --- | --- | --- |
| npm | JavaScript | The npm registry | package-lock.json |
| Yarn | JavaScript | The npm registry | yarn.lock |
| pnpm | JavaScript | The npm registry | pnpm-lock.yaml |
| Cargo | Rust | crates.io | Cargo.lock |
| Homebrew | Apps on macOS and Linux | Its own list | None |

## Which one to pick

1. **npm.** When you are starting out in JavaScript, because it comes with Node.js.
2. **Yarn or pnpm.** When the team already uses one. Or when you have many projects and want fast installs that share disk space.
3. **Cargo.** When you write Rust. There is no real choice, and that is a feature.
4. **Homebrew.** When you need a tool on your Mac or Linux machine, not a part of one project.

```console
$ pnpm add react
$ cargo new hello
$ cd hello
$ cargo run
Hello, world!
$ brew install wget
```
Add a package with pnpm, make and run a Rust project with Cargo, and install a tool with Homebrew. Cargo's own progress lines are cut.

![A table of four rows. JavaScript: npm, Yarn and pnpm, all fetching from the npm registry. Python: pip and uv, fetching from PyPI. Rust: Cargo, fetching from crates.io. Apps on Mac and Linux: Homebrew, fetching from its own list, called formulae. Each row runs from the language on the left, through its tools, to its registry on the right.](https://learn.benibix.com/diagrams/dev5-package-managers.svg)

### Example: Lucy saves disk space with pnpm

Lucy has 12 small JavaScript projects, each with its own copy of the same 300 packages. Together they take up 6 gigabytes.

She moves them to pnpm, which keeps one copy of each version and links the projects to it. The 12 projects now share under 1 gigabyte.

**Words in this lesson:** [Yarn](https://learn.benibix.com/term/development/yarn), [pnpm](https://learn.benibix.com/term/development/pnpm), [Cargo](https://learn.benibix.com/term/development/cargo), [Homebrew](https://learn.benibix.com/term/development/homebrew)

**Question:** Where do Yarn and pnpm get their packages from?

**Answer:** From the same npm registry that npm uses. Yarn and pnpm are other ways to do npm's job. They install in their own way, but the packages come from the one npm registry.

---

Source: https://learn.benibix.com/learn/development-tools/yarn-pnpm-cargo-and-homebrew
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.
