# pnpm — Fast, Disk-Space Efficient Package Manager > pnpm is a fast, disk-space efficient package manager for Node.js. Uses a content-addressable store and symlinks to avoid duplicating packages across projects — saves gigabytes and installs 2x faster than npm. ## Install Save in your project root: ## Quick Use ```bash # Install npm install -g pnpm # Or via Corepack (Node 16+) corepack enable # Use in a project pnpm install pnpm add react pnpm dlx create-vite my-app ``` Monorepo workspace: ```yaml # pnpm-workspace.yaml packages: - "apps/*" - "packages/*" ``` ```bash pnpm -r build # run build in all packages pnpm --filter web dev # run dev in the web package ``` ## Intro pnpm is a fast, disk-space efficient package manager. Uses a content-addressable store + symlinks so every version of every package exists once on disk, shared across all your projects. Solves npm/yarn disk bloat and duplication. - **Repo**: https://github.com/pnpm/pnpm - **Stars**: 34K+ - **Language**: TypeScript - **License**: MIT ## What pnpm Does - **Fast installs** — 2-3x faster than npm - **Disk efficient** — global content-addressable store (~/.pnpm-store) - **Strict node_modules** — no phantom dependencies - **Monorepo** — first-class workspace support - **Deterministic** — pnpm-lock.yaml - **Catalogs** — shared version ranges across workspace - **Patches** — patch-package built in ## Architecture Global store at `~/.pnpm-store/v3` holds all package tarballs (content-addressed). Each project gets a `node_modules/.pnpm` directory with hardlinks to the store, then symlinks in `node_modules/` to expose direct deps. Non-direct deps stay hidden (no phantom deps). ## Self-Hosting CLI tool — install locally, no server. ## Key Features - 2-3x faster than npm/yarn classic - Up to 50% disk space savings - Strict dependency resolution - Workspace/monorepo first-class - `pnpm dlx` for one-off commands - Built-in `pnpm patch` for upstream fixes - Catalogs (v9+) for shared versions - Side-effects cache ## Comparison | Manager | Speed | Disk | Monorepo | Strict | |---|---|---|---|---| | pnpm | Fast | Best | First-class | Yes | | Yarn Berry | Fast | Medium | First-class | PnP | | npm | Slowest | Worst | Workspaces | No | | Bun | Fastest | Good | Basic | No | ## 常见问题 FAQ **Q: 会破坏现有项目吗?** A: 少数依赖 phantom deps 的老包会报错。解决:把它们加到 `package.json` 或用 `public-hoist-pattern`。 **Q: 和 Turborepo/Nx 配合?** A: 完美配合。pnpm 管依赖,Turborepo/Nx 管任务编排和缓存。 **Q: 能替换 Yarn workspace 吗?** A: 能。迁移通常只需改 `package.json` 的 `workspaces` 为 `pnpm-workspace.yaml`。 ## 来源与致谢 Sources - Docs: https://pnpm.io - GitHub: https://github.com/pnpm/pnpm - License: MIT --- Source: https://tokrepo.com/en/workflows/2f0e07ae-3567-11f1-9bc6-00163e2b0d79 Author: AI Open Source