Skip to main content

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, 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
install30.6s8.1s7.1s3.4s
install1.3s858 毫秒5 秒n/a
install7.9s2.4s5.2s1.3s
install12.3s5.6s7 秒2.9s
install10.9s4.9s5.2s1.3s
install1.6s2.1s6.9sn/a
install1.3s874 毫秒5 秒n/a
install1.6s4.8s6.9sn/a
updaten/an/an/a6.5s3.3s5.7s3 秒
Graph of the alotta-files results