Skip to main content

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, no node_modules folder.

  • 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 the package.json and running the install command again.

大量文件

🌐 Lots of Files

该应用的 package.json 在这里

🌐 The app's package.json here

操作缓存锁定文件node_modulesnpmpnpmYarnYarn 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秒
Graph of the alotta-files results