Top Related Projects
The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
the package manager for JavaScript
Volta: JS Toolchains as Code. ⚡
A lightweight Node.js private proxy registry
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
Quick Overview
pnpm is a fast, disk space-efficient package manager for JavaScript and Node.js projects. It aims to solve common issues with npm and Yarn, such as duplicate dependencies and excessive disk usage, while maintaining compatibility with the npm ecosystem.
Pros
- Faster installation and updates compared to npm and Yarn
- Significantly reduced disk space usage due to its unique storage structure
- Built-in monorepo support with workspaces
- Strict mode for better dependency management and security
Cons
- Less widespread adoption compared to npm and Yarn
- Some tools and services may not fully support pnpm
- Learning curve for developers accustomed to npm or Yarn
- Potential compatibility issues with certain packages or build systems
Code Examples
- Installing a package:
pnpm add react
- Running a script defined in package.json:
pnpm run build
- Creating a new project with pnpm:
pnpm init
- Installing dependencies in a monorepo:
pnpm -r install
Getting Started
To get started with pnpm, follow these steps:
-
Install pnpm globally:
npm install -g pnpm
-
Initialize a new project:
mkdir my-project cd my-project pnpm init
-
Install dependencies:
pnpm add express
-
Create a simple server.js file:
const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello, pnpm!'); }); app.listen(port, () => { console.log(`Server running at http://localhost:${port}`); });
-
Run the server:
pnpm node server.js
Competitor Comparisons
The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
Pros of Yarn
- Wider adoption and community support
- Extensive plugin ecosystem
- Workspaces feature for monorepo management
Cons of Yarn
- Larger disk space usage due to node_modules structure
- Slower installation times compared to pnpm
- More complex caching mechanism
Code Comparison
Yarn:
dependencies:
lodash: ^4.17.21
scripts:
start: yarn run serve
pnpm:
dependencies:
lodash: ^4.17.21
scripts:
start: pnpm run serve
Both package managers use similar syntax for defining dependencies and scripts. The main difference lies in the command used to run scripts (yarn
vs pnpm
).
pnpm offers a more efficient disk space usage through its unique node_modules structure, which uses hard links and symbolic links. This results in faster installation times and reduced disk space consumption compared to Yarn.
Yarn provides a robust plugin system and has been widely adopted in the JavaScript ecosystem. It also offers workspaces for managing monorepos, which can be beneficial for larger projects.
While both package managers are actively maintained, pnpm has been gaining popularity due to its performance benefits and efficient disk usage. The choice between the two often depends on specific project requirements and team preferences.
the package manager for JavaScript
Pros of npm
- Widely adopted and supported by the Node.js ecosystem
- Extensive documentation and large community for troubleshooting
- Native integration with Node.js, requiring no additional installation
Cons of npm
- Slower installation and update processes compared to pnpm
- Larger disk space usage due to redundant package copies
- Potential for dependency conflicts and "dependency hell"
Code Comparison
npm:
{
"dependencies": {
"lodash": "^4.17.21",
"express": "^4.17.1"
}
}
pnpm:
{
"dependencies": {
"lodash": "^4.17.21",
"express": "^4.17.1"
}
}
The package.json files for both npm and pnpm are identical. The main differences lie in how these package managers handle dependencies internally:
- npm creates a nested node_modules structure with potential duplication
- pnpm uses a flat node_modules structure with symlinks, reducing disk space usage and improving installation speed
While the code itself doesn't differ, the resulting node_modules folder structure and performance characteristics vary significantly between npm and pnpm.
Volta: JS Toolchains as Code. ⚡
Pros of Volta
- Seamless tool version management across projects
- Automatic detection and use of project-specific Node.js versions
- Faster installation and switching between versions
Cons of Volta
- Limited to Node.js and JavaScript tools
- Smaller ecosystem and community compared to pnpm
- Less focus on package management and dependency resolution
Code Comparison
Volta (tool version management):
# Specify Node.js version for a project
volta pin node@14.17.0
# Install and use a specific npm version
volta install npm@7.19.1
pnpm (package management):
# Install dependencies
pnpm install
# Add a new package
pnpm add lodash
While both tools aim to improve the JavaScript development experience, they serve different primary purposes. Volta focuses on managing tool versions across projects, ensuring consistent environments. pnpm, on the other hand, is a package manager that emphasizes efficient dependency management and disk space usage.
Volta excels in providing a seamless experience for switching between Node.js versions and associated tools, making it ideal for developers working on multiple projects with different version requirements. pnpm shines in its approach to package management, offering faster installations and a more efficient use of disk space compared to npm or Yarn.
The choice between Volta and pnpm depends on the specific needs of the project and development team. They can be used together, with Volta managing tool versions and pnpm handling package management.
A lightweight Node.js private proxy registry
Pros of Verdaccio
- Acts as a private npm registry, allowing for local package hosting and offline development
- Provides a web interface for package management and user authentication
- Supports proxying to other registries, enabling caching and fallback mechanisms
Cons of Verdaccio
- Requires additional setup and maintenance compared to using a public registry
- May introduce complexity in CI/CD pipelines and deployment processes
- Limited scalability for large-scale enterprise environments
Code Comparison
Verdaccio configuration example:
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
proxy: npmjs
PNPM doesn't have a direct equivalent, as it's a package manager rather than a registry. However, here's an example of PNPM's configuration file:
hoist: true
shamefully-hoist: true
store-dir: .pnpm-store
While Verdaccio focuses on creating a private registry, PNPM is a package manager that aims to improve dependency management and installation speed. They serve different purposes in the JavaScript ecosystem, with Verdaccio providing a solution for private package hosting and PNPM offering an alternative to npm and Yarn for package management.
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
Pros of nvm
- Allows easy switching between Node.js versions
- Supports installation of multiple Node.js versions on a single system
- Widely adopted and well-established in the Node.js community
Cons of nvm
- Limited to Node.js version management only
- Requires manual switching between versions for different projects
- Can be slower to install and use compared to pnpm
Code Comparison
nvm:
nvm install 14.17.0
nvm use 14.17.0
node -v
pnpm:
pnpm env use --global 14.17.0
pnpm install
pnpm run start
Key Differences
- pnpm is a package manager with additional features like Node.js version management, while nvm focuses solely on Node.js version management
- pnpm offers faster package installation and disk space efficiency
- nvm provides more granular control over Node.js versions
- pnpm integrates package management and version control, while nvm requires separate package management tools
Use Cases
- Choose nvm for projects requiring frequent switching between Node.js versions
- Opt for pnpm in projects prioritizing fast package installation and efficient disk space usage
- Consider pnpm for monorepo setups and large-scale projects
- Use nvm when working with legacy Node.js versions or specific version requirements
Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
Pros of asdf
- Supports multiple programming languages and tools, not just JavaScript
- Allows managing versions of various tools in a single configuration file
- Provides a consistent interface for version management across different technologies
Cons of asdf
- Requires more setup and configuration compared to pnpm's simplicity
- May have a steeper learning curve for users familiar with language-specific version managers
- Less optimized for JavaScript/Node.js ecosystem-specific features
Code Comparison
asdf:
asdf plugin add nodejs
asdf install nodejs 14.17.0
asdf global nodejs 14.17.0
pnpm:
pnpm env use --global 14.17.0
pnpm install
pnpm run start
While asdf focuses on managing versions of multiple tools, pnpm is specifically designed for JavaScript package management and provides additional features like efficient disk space usage and deterministic installs. asdf offers more flexibility across languages, but pnpm excels in its specialized domain with faster installations and better integration with Node.js projects. The choice between the two depends on whether you need a multi-language version manager or a JavaScript-specific package manager with advanced features.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ç®ä½ä¸æ | æ¥æ¬èª | íêµì´ | Italiano | Português Brasileiro

Fast, disk space efficient package manager:
- Fast. Up to 2x faster than the alternatives (see benchmark).
- Efficient. Files inside
node_modules
are linked from a single content-addressable storage. - Great for monorepos.
- Strict. A package can access only dependencies that are specified in its
package.json
. - Deterministic. Has a lockfile called
pnpm-lock.yaml
. - Works as a Node.js version manager. See pnpm env use.
- Works everywhere. Supports Windows, Linux, and macOS.
- Battle-tested. Used in production by teams of all sizes since 2016.
- See the full feature comparison with npm and Yarn.
To quote the Rush team:
Microsoft uses pnpm in Rush repos with hundreds of projects and hundreds of PRs per day, and weâve found it to be very fast and reliable.
Platinum Sponsors
|
|
|
Gold Sponsors
|
|
|
|
|
|
|
|
|
Silver Sponsors
![]() |
|
|
|
|
|
|
|
|
|
Support this project by becoming a sponsor.
Background
pnpm uses a content-addressable filesystem to store all files from all module directories on a disk. When using npm, if you have 100 projects using lodash, you will have 100 copies of lodash on disk. With pnpm, lodash will be stored in a content-addressable storage, so:
- If you depend on different versions of lodash, only the files that differ are added to the store.
If lodash has 100 files, and a new version has a change only in one of those files,
pnpm update
will only add 1 new file to the storage. - All the files are saved in a single place on the disk. When packages are installed, their files are linked from that single place consuming no additional disk space. Linking is performed using either hard-links or reflinks (copy-on-write).
As a result, you save gigabytes of space on your disk and you have a lot faster installations!
If you'd like more details about the unique node_modules
structure that pnpm creates and
why it works fine with the Node.js ecosystem, read this small article: Flat node_modules is not the only way.
ð Like this project? Let people know with a tweet
Getting Started
Benchmark
pnpm is up to 2x faster than npm and Yarn classic. See all benchmarks here.
Benchmarks on an app with lots of dependencies:
License
Top Related Projects
The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
the package manager for JavaScript
Volta: JS Toolchains as Code. ⚡
A lightweight Node.js private proxy registry
Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot