Skip to main content

JavaScript 包管理器的基准测试

¥Benchmarks of JavaScript Package Managers

上次基准测试时间:2025 年 9 月 21 日,凌晨 3:04(每日更新)。

¥Last benchmarked at: Sep 21, 2025, 3:04 AM (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, no node_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 the package.json and running the install command again.

大量文件

¥Lots of Files

应用的 package.json 此处

¥The app's package.json here

actioncachelockfilenode_modulesnpmpnpmYarnYarn PnP
install32.5s8.7s7.3s3.6s
install1.3s764 毫秒5.3sn/a
install8 秒2.4s5.4s1.3s
install12.6s6 秒7.5s3.1s
install11.1s5.2s5.5s1.3s
install1.6s2.1s7.2sn/a
install1.3s746 毫秒5.3sn/a
install1.6s5.2s7.2sn/a
updaten/an/an/a6.8s3.4s5.8s3.2s
Graph of the alotta-files results