Convert Figma logo to code with AI

pnpm logopnpm

Fast, disk space efficient package manager

30,544
1,056
30,544
1,762

Top Related Projects

41,478

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry

8,637

the package manager for JavaScript

11,413

Volta: JS Toolchains as Code. ⚡

16,639

A lightweight Node.js private proxy registry

81,764

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

22,490

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

  1. Installing a package:
pnpm add react
  1. Running a script defined in package.json:
pnpm run build
  1. Creating a new project with pnpm:
pnpm init
  1. Installing dependencies in a monorepo:
pnpm -r install

Getting Started

To get started with pnpm, follow these steps:

  1. Install pnpm globally:

    npm install -g pnpm
    
  2. Initialize a new project:

    mkdir my-project
    cd my-project
    pnpm init
    
  3. Install dependencies:

    pnpm add express
    
  4. 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}`);
    });
    
  5. Run the server:

    pnpm node server.js
    

Competitor Comparisons

41,478

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.

8,637

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.

11,413

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.

16,639

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.

81,764

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
22,490

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

简体中文 | 日本語 | 한국어 | Italiano | Português Brasileiro

pnpm

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.

npm version Join the chat at Discord OpenCollective OpenCollective X Follow Stand With Ukraine

Platinum Sponsors

Bit Bit Figma

Gold Sponsors

Discord Prisma
u|screen JetBrains
Nx CodeRabbit
Route4Me Workleap
Canva

Silver Sponsors

Leniolabs_ Vercel Depot
moonrepo devowl.io Cerbos
vlt Vite
Vite

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:

  1. 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.
  2. 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

MIT

NPM DownloadsLast 30 Days