Skip to content

Guide · Open source

How to use pnpm: install, lockfile, monorepos and FAQs

Updated · written with AI from the project's own documentation and checked against our catalogue data

pnpm is an open-source package manager for JavaScript and Node.js projects. It downloads and installs the libraries your project depends on, and its README says it does this faster and with less disk space than many alternatives. This guide explains what pnpm does, how its store, strict dependency rules and lockfile work, and when it is a good or poor fit.

pnpmpnpm/pnpm · ★ 37k · MIT

Quick start

  1. 1Check your project. Confirm you are in a Node.js project folder with a package.json file, since pnpm manages the dependencies listed there.
  2. 2Install pnpm. Follow the current installation instructions at pnpm.io, because the README does not list install commands.
  3. 3Install dependencies. Use pnpm in the project folder to download and link the libraries your package.json declares.
  4. 4Keep the lockfile. Keep pnpm-lock.yaml with the project so installs stay repeatable for everyone who works on it.
  5. 5Respect strict dependencies. Declare every package your code imports in its own package.json, because pnpm only lets a package access what it lists.
  6. 6Explore monorepos. If you have several packages in one repository, read the workspaces documentation at pnpm.io/workspaces.

What pnpm does and where it fits

pnpm sits where npm and Yarn sit: it manages the packages a Node.js project depends on. According to its README, pnpm is fast, disk-efficient, strict, deterministic and works on Windows, Linux and macOS.

The README also lists pnpm as a Node.js version manager through its pnpm runtime feature, and includes an experimental Rust port of the CLI called pacquet.

  • Fast: the README claims up to 2x faster than the alternatives, and links to a benchmark.
  • Efficient: files inside node_modules are linked from a single content-addressable storage.
  • Strict: a package can access only the dependencies listed in its own package.json.
  • Deterministic: it uses a lockfile called pnpm-lock.yaml.

Install pnpm before your first project

The README does not list install commands or prerequisites, so check the official site at pnpm.io for current installation instructions. Install method for this project is listed as a package manager.

Once installed, you use pnpm from the terminal inside a Node.js project folder that contains a package.json file.

  • Read the installation section on https://pnpm.io.
  • Confirm the command works in your terminal before starting a project.

Instead of copying each library into every project, pnpm keeps files in a single content-addressable store. Files inside node_modules are linked from that store, which is the source of the disk savings described in the README.

Strictness follows from the same design. A package can only import dependencies declared in its own package.json, which helps prevent accidental imports of packages you never declared.

Use the pnpm-lock.yaml lockfile for repeatable installs

pnpm writes its lockfile to pnpm-lock.yaml. The lockfile records the resolved dependency state so that installs are repeatable across machines.

Keep the lockfile with your project so teammates and build systems install the same dependency versions.

Set up a monorepo with multiple packages

The README says pnpm is great for monorepos, meaning one repository that holds multiple packages. Its workspaces documentation at pnpm.io/workspaces explains how to set this up.

The README also notes that teams of all sizes use pnpm in production, and quotes Microsoft's Rush team saying they found it very fast and reliable in Rush repos with hundreds of projects.

Check whether pnpm is the right fit

pnpm is a good match for Node.js developers who want faster installs, less disk use, strict dependency declarations and a lockfile. It is less suitable where a project depends on behaviour specific to npm or Yarn, because switching package managers can require changes.

The README points to a feature comparison page at pnpm.io/feature-comparison for details. The experimental Rust port, pacquet, is not the default CLI, so it only matters if you plan to try it.

  • Good fit: Node.js projects, monorepos, strict dependency rules, reproducible installs.
  • Poor fit: non-developers, or projects that rely on npm or Yarn specific behaviour.

What people use it for

  • Speeding up installs for a Node.js app with many dependencies.
  • Saving disk space across several projects that share libraries.
  • Running a monorepo with multiple packages in one repository.
  • Catching accidental imports by enforcing declared dependencies.
  • Keeping dependency installs reproducible with pnpm-lock.yaml.

Frequently asked questions

Is pnpm free to use?

Yes. The project is listed under the MIT licence, which is a permissive open-source licence. Check the licence file in the repository if you need the exact terms.

What are the requirements for pnpm?

The source does not list prerequisites. The README says pnpm supports Windows, Linux and macOS, and it is used in Node.js projects. Check pnpm.io for current setup requirements.

Is pnpm faster than npm?

The README claims pnpm is up to 2x faster than the alternatives and links to a benchmark. Test it on your own project before relying on that figure.

How does pnpm compare to npm and Yarn?

The README links to a full feature comparison with npm and Yarn at pnpm.io/feature-comparison. Projects that depend on npm or Yarn specific behaviour may need changes to switch.

What is pnpm-lock.yaml?

It is the lockfile pnpm uses to make installs repeatable. It records the dependency state so that everyone installing the project gets the same result.

Are there alternatives to pnpm?

The source lists npm, Yarn and Bun as comparable projects. Pick the one whose behaviour matches what your project needs.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

pnpm suits Node.js developers and teams who want faster installs, less disk use, strict dependency declarations and a lockfile, especially in monorepos. If your project depends on npm or Yarn specific behaviour, or you need a tool with no unknowns for critical production use, compare it with npm, Yarn and Bun first.

Install options & downloads