新pnpm 12 有哪些不同

节省时间,节省磁盘空间,让你的 monorepo 焕然一新。

获得闪电般的安装速度和更智能、更安全的依赖项管理方式。

curl -fsSL https://get.pnpm.io | sh -

使用 pnpm 的开源项目

  • next.js
  • n8n
  • Material UI
  • Vite
  • Nuxt
  • Vue
  • Astro
  • Prisma
  • Novu
  • Slidev
  • Turborepo
  • Quasar Framework
  • Element Plus
  • NextAuth.js
  • Ember.js
  • Qwik
  • VueUse
  • SvelteKit
  • Verdaccio
  • Vercel
  • Nx
  • Angular
Benchmarks

Up to 69× faster than npm

Measured on a real project, across the states an install actually happens in — from a fresh clone to a warm re-run. Reproducible, and rebuilt on every deploy.

8.2×faster in total, across all 6 scenarios
10.8svs 1m 28s with npm
Explore the full benchmarks
alotta-filespnpm 12npm
  • cleanA fresh clone. Nothing cached.9.6× faster
    4.97s
    47.8s
  • cacheReinstalling without a lockfile.14× faster
    952ms
    13.4s
  • lockfileCI, first install.3.8× faster
    3.31s
    12.7s
  • cache + lockfileReinstalling a project you already have.14× faster
    595ms
    8.61s
  • everything warmRunning install when nothing changed.69× faster
    19ms
    1.32s
  • updateA dependency was bumped in package.json.4.6× faster
    968ms
    4.43s

你期待的一切,以及那些你未曾想到要问的功能

pnpm 可直接替代 npm——而且不止于此,还提供了大型仓库真正需要的功能。

极速安装

解析、获取和链接并行进行,而不是一个阶段接一个阶段。在热存储下,安装主要就是创建链接。

查看基准测试

节省磁盘空间

node_modules 内的文件通过硬链接来自单一的内容寻址存储。同一版本的一百个项目在磁盘上只占用一份副本。

Learn more

工作空间支持

一流的 monorepo 支持:用于本地包的 workspace 协议、只在你改动过的项目上运行任务的过滤功能,以及为所有内容使用单一锁文件。

Learn more

Catalogs

在 pnpm-workspace.yaml 中定义一次依赖版本,然后在各处引用为 "catalog:"。升级只需一行,不再有版本漂移导致的合并冲突。

Learn more

默认严格

只有你声明的依赖才会出现在 node_modules 的根目录中,因此你的代码永远不会悄悄导入一个你从未安装过的包。

Learn more

更安全的构建

安装脚本不会为任意依赖运行。你可以批准哪些包可以执行构建脚本——无需额外工具即可实现供应链安全。

Learn more

修补依赖项

无需等待上游即可修复包中的 bug——"pn patch" 会写入一个持久补丁,并在每次安装时重新应用。

Learn more

管理运行时

直接从 pnpm 按项目安装并固定 Node.js 版本——无需 nvm,无需 shell 钩子,也不会出现“在我机器上能跑”的版本不匹配问题。

Learn more

How it works

A single store on disk, linked everywhere

Other package managers copy the same files into every project. pnpm keeps one copy and links to it — that single design decision is where the speed and the disk savings come from.

  • One copy per file, not per project

    With npm, 100 projects using the same dependency means 100 copies on disk. pnpm stores every file once in a content-addressable store and hard-links it into each node_modules.

  • Updates only store what changed

    If a new version of a package changes one file out of a hundred, pnpm adds exactly one file to the store instead of cloning the whole package again.

  • A node_modules you can trust

    pnpm symlinks only your declared dependencies into the root of node_modules, so your code can never quietly import a package you never installed.

  • Resolve, fetch and link in parallel

    Instead of finishing each stage before starting the next, pnpm links every package as soon as it is available — which is why installs feel instant on a warm store.

Content-addressable storea1f3…9c×4b7e2…41×3e94d…7a×45c08…d2×42f6b…e08d1c…3b×2c4a9…f6×271e5…08×4app/node_modulesreact/index.jsreact-dom/index.jslodash/lodash.jszod/index.jsweb/node_modulesreact/index.jsreact-dom/index.jsms/index.jszod/index.jsdocs/node_modulesreact/index.jsreact-dom/index.jsms/index.jstypescript/tsc.jsapi/node_modulesexpress/index.jslodash/lodash.jsms/index.jszod/index.jsadmin/node_modulesreact/index.jslodash/lodash.jschalk/index.jszod/index.jscli/node_moduleschalk/index.jstypescript/tsc.jsms/index.jslodash/lodash.js24 files in node_modules → 8 on disk
1 copy

of every file on your disk, shared across all projects

0 bytes

extra disk space when a project reuses a version you already have

Strict

no access to undeclared dependencies, by default

pnpm vs npm

Everything npm does, plus the features that make large repos manageable.

Featurepnpmnpm
Content-addressable storage✓—
CatalogsShared version ranges across a workspace.✓—
Managing runtimesInstall Node.js without nvm.✓—
Patching dependencies✓—
Side-effects cache✓—
Build script securityScripts only run for packages you allow.✓—

See the full feature comparison in the documentation.

Releases

Recent releases

New features, fixes and security updates ship almost every week. Each square is a day; coloured ones shipped a release.

Loved by developers

The package manager we should have had all along

Teams switch to pnpm for the speed and stay for how cleanly it handles dependencies and monorepos.

@pnpmjs is a strong option for protecting against supply chain attacks, and the DX is excellent too they removed postinstall scripts a while back, cutting one big attack path now they’ve introduced minimumReleaseAge which lets you hold off on new versions for a day or more
Its not even been a day but I suddenly feel that @pnpmjs has improved my overall dev experience 🤯
This whole time I've stuck with npm out of habit and because it "just works". But then I had to override a subdependency via package.json, and npm just wouldn't do it. I spent hours fiddling. So @darcy recommends I use @pnpmjs , and w/ the same package.json, it "just works".
Gotta say @pnpmjs has never let me down. Great piece of software.
By adopting the latest changes from @pnpmjs we got huge performance benefits in @bitdev_ ! still early to call true numbers, but i'm seeing decreases of 40% in some flows! incredible work by @ZoltanKochan and the team behind pnpm!
I ❤️ pnpm. Just radically sped up a CI build by switching to pnpm and parallelizing tasks (which pnpm supports built-in) Before: 12 minutes After: 2 minutes 😀
Zero-bug policy

Zero open bugs. Always.

Our goal is zero open bug reports at all times. A bug with steps to reproduce is picked up quickly and fixed as soon as possible.

Live from GitHub0open bug reports is the goal
  1. Report it with a reproduction

    Open an issue with the steps, or a small repository, that reproduce the bug.

  2. It gets picked up fast

    Reproducible bugs go to the top of the queue. The issue list is kept at zero.

  3. Fixed in the next release

    Fixes ship quickly, usually in the next patch or minor release.

  4. Report a bugSuggest a feature

Issues are for bugs only. Feature requests and questions live in GitHub Discussions.

Ready to reclaim your disk and your time?

pnpm is a drop-in replacement for npm. Install it once, run pnpm install in any project — your package.json works as-is.

curl -fsSL https://get.pnpm.io | sh -