JavaScript 包管理器的基准测试
🌐 Benchmarks of JavaScript Package Managers
上次基准测试时间:2026年7月6日 上午9:42(_每日_更新)。
此基准测试比较了 npm、pnpm、Yarn Classic 和 Yarn PnP 的性能(有关未在此处包含的其他 Yarn 模式,请查看 Yarn 的基准测试)。
🌐 This benchmark compares the performance of npm, pnpm, Yarn Classic, and Yarn PnP (check Yarn's benchmarks for any other Yarn modes that are not included here).
每一行的标签列出了在安装运行之前 cache、lockfile 和 node_modules 哪些是热/存在的。快速映射到现实世界(按从最慢到最快的场景排序):
🌐 Each row's label lists which of cache, lockfile, and node_modules are warm/present before install runs. Quick mapping to the real world (ordered from slowest to fastest scenario):
-
clean: a brand-new clone — nothing cached, no lockfile, nonode_modules. -
cache: a developer reinstalling without a lockfile. -
lockfile: a CI server doing its first install. -
cache+lockfile: a developer reinstalling a known project. -
node_modules: the cache and lockfile are deleted and install is run again. -
cache+node_modules: the lockfile is deleted and install is run again. -
lockfile+node_modules: the cache is deleted and install is run again. -
cache+lockfile+node_modules: re-running install when nothing has changed. -
update: dependency versions are bumped inpackage.jsonand install is run again.
大量文件
🌐 Lots of Files
该应用的 package.json 在这里
🌐 The app's package.json here
| 操作 | 缓存 | 锁文件 | node_modules | npm | pnpm | pnpm 🦀 | Yarn | Yarn PnP |
|---|---|---|---|---|---|---|---|---|
| 安装 | 31.3s | 7.7s | 2.3s | 7s | 2.7s | |||
| 安装 | ✔ | 13.8s | 4.5s | 1.3s | 7s | 2.3s | ||
| 安装 | ✔ | 12.5s | 6.4s | 1.9s | 5s | 1s | ||
| 安装 | ✔ | ✔ | 9s | 2.3s | 603ms | 5.4s | 1.1s | |
| 安装 | ✔ | 1.7s | 576ms | 47ms | 6.3s | 不适用 | ||
| 安装 | ✔ | ✔ | 1.7s | 557ms | 48ms | 6.3s | 不适用 | |
| 安装 | ✔ | ✔ | 1.3s | 520ms | 62ms | 4.6s | 不适用 | |
| 安装 | ✔ | ✔ | ✔ | 1.3s | 510ms | 13ms | 4.5s | 不适用 |
| 更新 | 不适用 | 不适用 | 不适用 | 6.9s | 7.5s | 2.1s | 5.1s | 2.3s |
pnpm vs pnpm 🦀
pnpm v12 将使用一个用 Rust 编写的新安装引擎来进行获取和链接。详见 pacquet。
🌐 pnpm v12 will use a new installation engine for fetching and linking written in Rust. See pacquet.
| 操作 | 缓存 | 锁文件 | node_modules | pnpm | pnpm 🦀 |
|---|---|---|---|---|---|
| 安装 | 7.7秒 | 2.3秒 | |||
| 安装 | ✔ | 6.4秒 | 1.9秒 | ||
| 安装 | ✔ | 4.5秒 | 1.3秒 | ||
| 安装 | ✔ | ✔ | 2.3秒 | 603毫秒 | |
| 安装 | ✔ | 576毫秒 | 47毫秒 | ||
| 安装 | ✔ | ✔ | 557毫秒 | 48毫秒 | |
| 安装 | ✔ | ✔ | 520毫秒 | 62毫秒 | |
| 安装 | ✔ | ✔ | ✔ | 510毫秒 | 13毫秒 |
| 更新 | 不适用 | 不适用 | 不适用 | 7.5秒 | 2.1秒 |