How to use pnpm: a simple guide

pnpm is a package manager for JavaScript. It is like npm or yarn, but it is faster and uses less disk space.

Why?

  • pnpm saves only one copy of each version of a package.
  • Many projects can share the same files.
  • This makes your computer cleaner and faster.

Install pnpm on your system:

1
npm install -g pnpm

Now you can use pnpm in any project.


Go to your project folder and run:

1
pnpm install

This will install all packages from package.json.


Add a package to your project:

1
pnpm add lodash

For development only:

1
pnpm add -D typescript

Use a tool everywhere:

1
pnpm add -g serve

Delete a package from your project:

1
pnpm remove lodash

Update all packages:

1
pnpm update

Update a specific package:

1
pnpm update lodash

Install dependencies and run tests:

1
pnpm install-test

This is useful to check if everything works after install.


1
pnpm --help

pnpm is a smart, fast, and space-saving package manager. With simple commands like install, add, remove, update, and install-test, you can manage your project dependencies easily.