Skip to main content

JavaScript 包管理器的基准测试

🌐 Benchmarks of JavaScript Package Managers

上次基准测试时间2026年7月6日 上午9:42(_每日_更新)。

此基准测试比较了 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).

每一行的标签列出了在安装运行之前 cachelockfilenode_modules 哪些是热/存在的。快速映射到现实世界(按从最慢到最快的场景排序):

🌐 Each row's label lists which of cache, lockfile, and node_modules are warm/present before install runs. Quick mapping to the real world (ordered from slowest to fastest scenario):

  • clean: a brand-new clone — nothing cached, no lockfile, no node_modules.

  • cache: a developer reinstalling without a lockfile.

  • lockfile: a CI server doing its first install.

  • cache+lockfile: a developer reinstalling a known project.

  • node_modules: the cache and lockfile are deleted and install is run again.

  • cache+node_modules: the lockfile is deleted and install is run again.

  • lockfile+node_modules: the cache is deleted and install is run again.

  • cache+lockfile+node_modules: re-running install when nothing has changed.

  • update: dependency versions are bumped in package.json and install is run again.

大量文件

🌐 Lots of Files

该应用的 package.json 在这里

🌐 The app's package.json here

操作缓存锁文件node_modulesnpmpnpmpnpm 🦀YarnYarn PnP
安装31.3s7.7s2.3s7s2.7s
安装13.8s4.5s1.3s7s2.3s
安装12.5s6.4s1.9s5s1s
安装9s2.3s603ms5.4s1.1s
安装1.7s576ms47ms6.3s不适用
安装1.7s557ms48ms6.3s不适用
安装1.3s520ms62ms4.6s不适用
安装1.3s510ms13ms4.5s不适用
更新不适用不适用不适用6.9s7.5s2.1s5.1s2.3s
Graph of the alotta-files results

pnpm vs pnpm 🦀

pnpm v12 将使用一个用 Rust 编写的新安装引擎来进行获取和链接。详见 pacquet

🌐 pnpm v12 will use a new installation engine for fetching and linking written in Rust. See pacquet.

操作缓存锁文件node_modulespnpmpnpm 🦀
安装7.7秒2.3秒
安装6.4秒1.9秒
安装4.5秒1.3秒
安装2.3秒603毫秒
安装576毫秒47毫秒
安装557毫秒48毫秒
安装520毫秒62毫秒
安装510毫秒13毫秒
更新不适用不适用不适用7.5秒2.1秒
Graph comparing pnpm versions on the alotta-files fixture