JavaScript 包管理器的基准测试
🌐 Benchmarks of JavaScript Package Managers
最后测试时间:2026年2月22日,上午3:31(每日更新)。
此基准测试比较了 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).
以下是这些测试如何应用于实际环境的简要说明:
🌐 Here's a quick explanation of how these tests could apply to the real world:
-
clean install: How long it takes to run a totally fresh install: no lockfile present, no packages in the cache, nonode_modulesfolder. -
with cache,with lockfile,with node_modules: After the first install is done, the install command is run again. -
with cache,with lockfile: When a repo is fetched by a developer and installation is first run. -
with cache: Same as the one above, but the package manager doesn't have a lockfile to work from. -
with lockfile: When an installation runs on a CI server. -
with cache,with node_modules: The lockfile is deleted and the install command is run again. -
with node_modules,with lockfile: The package cache is deleted and the install command is run again. -
with node_modules: The package cache and the lockfile is deleted and the install command is run again. -
update: Updating your dependencies by changing the version in thepackage.jsonand running the install command again.
大量文件
🌐 Lots of Files
该应用的 package.json 在这里
🌐 The app's package.json here
| 操作 | 缓存 | 锁定文件 | node_modules | npm | pnpm | Yarn | Yarn PnP |
|---|---|---|---|---|---|---|---|
| 安装 | 39.1秒 | 9.7秒 | 7.2秒 | 3.5秒 | |||
| 安装 | ✔ | ✔ | ✔ | 1.3秒 | 747毫秒 | 5.1秒 | 不适用 |
| 安装 | ✔ | ✔ | 9.5秒 | 2.4秒 | 5.2秒 | 1.3秒 | |
| 安装 | ✔ | 14.2秒 | 6秒 | 7.3秒 | 2.9秒 | ||
| 安装 | ✔ | 12.7秒 | 5.8秒 | 5.3秒 | 1.3秒 | ||
| 安装 | ✔ | ✔ | 2秒 | 2.2秒 | 7秒 | 不适用 | |
| 安装 | ✔ | ✔ | 1.3秒 | 746毫秒 | 5.1秒 | 不适用 | |
| 安装 | ✔ | 2秒 | 5.8秒 | 7秒 | 不适用 | ||
| 更新 | 不适用 | 不适用 | 不适用 | 7.8秒 | 3.2秒 | 5.7秒 | 3秒 |