How to use pnpm: a simple guide
Contents
1 What is pnpm?
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.
2 Basic Use Cases
2.1 Install pnpm globally
Install pnpm on your system:
|
|
Now you can use pnpm
in any project.
2.2 Install packages for a project
Go to your project folder and run:
|
|
This will install all packages from package.json
.
2.3 Install one package
Add a package to your project:
|
|
For development only:
|
|
2.4 Install a package globally
Use a tool everywhere:
|
|
3 Other Common Commands
3.1 Remove a package
Delete a package from your project:
|
|
3.2 Update packages
Update all packages:
|
|
Update a specific package:
|
|
3.3 Install and run tests
Install dependencies and run tests:
|
|
This is useful to check if everything works after install.
3.4 For help
|
|
4 Conclusion
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.