JavaScript 包管理器的基准测试
¥Benchmarks of JavaScript Package Managers
上次基准测试时间:2025 年 5 月 18 日 下午 12:54(每日更新)。
¥Last benchmarked at: May 18, 2025, 12:54 PM (daily updated).
此基准测试比较了 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
:运行全新安装需要多长时间:不存在锁定文件,缓存中没有软件包,没有node_modules
文件夹。¥
clean install
: How long it takes to run a totally fresh install: no lockfile present, no packages in the cache, nonode_modules
folder. -
with cache
,with lockfile
,with node_modules
:首次安装完成后,将再次运行安装命令。¥
with cache
,with lockfile
,with node_modules
: After the first install is done, the install command is run again. -
with cache
,with lockfile
:当开发者获取仓库并首次运行安装时。¥
with cache
,with lockfile
: When a repo is fetched by a developer and installation is first run. -
with cache
:与上述测试相同,但包管理器没有可用的锁文件。¥
with cache
: Same as the one above, but the package manager doesn't have a lockfile to work from. -
with lockfile
:当安装在 CI 服务器上运行时。¥
with lockfile
: When an installation runs on a CI server. -
with cache
,with node_modules
:锁文件将被删除,然后再次运行安装命令。¥
with cache
,with node_modules
: The lockfile is deleted and the install command is run again. -
with node_modules
,with lockfile
:包缓存将被删除,然后再次运行安装命令。¥
with node_modules
,with lockfile
: The package cache is deleted and the install command is run again. -
with node_modules
:包缓存和锁文件将被删除,然后再次运行安装命令。¥
with node_modules
: The package cache and the lockfile is deleted and the install command is run again. -
update
:通过更改package.json
中的版本并再次运行安装命令来更新依赖。¥
update
: Updating your dependencies by changing the version in thepackage.json
and running the install command again.
大量文件
¥Lots of Files
应用的 package.json
此处
¥The app's package.json
here
action | cache | lockfile | node_modules | npm | pnpm | Yarn | Yarn PnP |
---|---|---|---|---|---|---|---|
install | 30.6s | 8.1s | 7.1s | 3.4s | |||
install | ✔ | ✔ | ✔ | 1.3s | 858 毫秒 | 5 秒 | n/a |
install | ✔ | ✔ | 7.9s | 2.4s | 5.2s | 1.3s | |
install | ✔ | 12.3s | 5.6s | 7 秒 | 2.9s | ||
install | ✔ | 10.9s | 4.9s | 5.2s | 1.3s | ||
install | ✔ | ✔ | 1.6s | 2.1s | 6.9s | n/a | |
install | ✔ | ✔ | 1.3s | 874 毫秒 | 5 秒 | n/a | |
install | ✔ | 1.6s | 4.8s | 6.9s | n/a | ||
update | n/a | n/a | n/a | 6.5s | 3.3s | 5.7s | 3 秒 |