pnpm 的2021年
又到了一年年末,这一年对 pnpm 来说是美好的一年,让我们来看看它的进展如何。
🌐 It is the end of the year and it was a good year for pnpm, so let's see how it went.
用法
🌐 Usage
下载统计
🌐 Download Stats
我今年的目标是通过下载量超过 Bower。我们能够在 十一月 实现这个目标:
🌐 My goal this year was to beat Bower by the number of downloads. We were able to achieve this goal in November:

2021 年 pnpm 的下载量大约是 2020 年的 3 倍:
🌐 pnpm was downloaded about 3 times more in 2021 than in 2020:

这些统计数据甚至没有衡量 pnpm 可能被安装的所有不同方式! 它们只衡量 pnpm npm 包 的下载量。今年我们还添加了 pnpm 的编译二进制版本,这些版本的发布方式不同。
🌐 These stats don't even measure all the different ways that pnpm may be installed! They only measure the downloads of the pnpm npm package. This year we also added compiled binary versions of pnpm, which are shipped differently.
查看文档
🌐 Docs visits
我们使用 Google Analytics 从我们的文档中收集一些非个性化的统计数据。2021 年,有时我们每周的独立访问者超过 2,000 人。
🌐 We collect some unpersonalized stats from our docs using Google Analytics. In 2021, sometimes we had more than 2,000 unique visitors a week.

我们的大多数用户来自美国和中国。
🌐 Most of our users are from the United States and China.

GitHub 星标
🌐 GitHub stars
我们 的 主要 GitHub 仓库 今年获得了 +5,000 个星标。
🌐 Our main GitHub repository received +5,000 stars this year.

新用户
🌐 New users
我们今年最大的新增用户是字节跳动(TikTok的背后公司)。
🌐 Our biggest new user this year is Bytedance (the company behind TikTok).
此外,许多优秀的开源项目开始使用 pnpm。一些项目转向 pnpm 是因为它对 monorepos 的出色支持:
🌐 Also, many great open-source projects started to use pnpm. Some switched to pnpm because of its great support of monorepos:
有些人换用是因为他们喜欢 pnpm 的高效、快速和美观:
🌐 Some switched because they like how efficient, fast, and beautiful pnpm is:
功能亮点
🌐 Feature Highlights
新的锁文件格式(自 v6.0.0 起)
🌐 New lockfile format (since v6.0.0)
今年的第一个也是最重要的变化之一是新的 pnpm-lock.yaml 格式。这是一个重大变更,因此我们不得不发布 v6。但它取得了成功。旧的锁定文件经常导致 Git 冲突。自从引入新格式以来,我们没有收到关于 Git 冲突的任何投诉。
🌐 One of the first and most important changes this year was the new pnpm-lock.yaml format. This was a breaking change, so we had to release v6. But it was a success. The old lockfile was causing Git conflicts frequently. Since the new format was introduced, we did not receive any complaints about Git conflicts.
管理 Node.js 版本(自 v6.12.0 起)
🌐 Managing Node.js versions (since v6.12.0)
我们发布了一个新命令(pnpm env),它允许管理 Node.js 版本。因此,你可以使用 pnpm 来代替像 nvm 或 Volta 这样的 Node.js 版本管理器。
🌐 We shipped a new command (pnpm env) that allows to manage Node.js versions. So you may use pnpm instead of Node.js version managers like nvm or Volta.
此外,pnpm 作为独立可执行文件提供,因此即使系统上没有预先安装 Node.js,你也可以运行它。
🌐 Also, pnpm is shipped as a standalone executable, so you can run it even with no Node.js preinstalled on the system.
注入本地依赖(自 v6.20.0 起)
🌐 Injecting local dependencies (since v6.20.0)
你可以“注入”本地依赖。默认情况下,本地依赖会被符号链接到 node_modules,但有了这个新功能,你可以指示 pnpm 将包的文件硬链接起来。
🌐 You may "inject" a local dependency. By default, local dependencies are symlinked to node_modules but with this new feature you may instruct pnpm to hard link the files of the package instead.
改进了对同伴依赖问题的报告(自 v6.24.0 起)
🌐 Improved reporting of peer dependency issues (since v6.24.0)
以前,同行依赖问题会以纯文本的形式打印出来,很难理解。现在它们都被分组并以漂亮的层次结构打印。
🌐 Peer dependency issues used to be printed as plain text and it was hard to understand them. They are now all grouped and printed in a nice hierarchy structure.
比赛
🌐 The Competition
Yarn
Yarn 在 v3.1 中添加了 pnpm 链接器。因此,Yarn 可以创建与 pnpm 创建的 node-modules 目录结构类似的结构。
🌐 Yarn added a pnpm linker in v3.1. So Yarn can create a similar node-modules directory structure to the one that pnpm creates.
此外,Yarn 团队计划实现内容可寻址存储,以提高磁盘空间利用效率。
🌐 Also, the Yarn team plans to implement a content-addressable storage to be more disk space efficient.
npm
npm 团队决定也采用 pnpm 使用的符号链接 node-modules 目录结构(相关 RFC)。
🌐 The npm team decided to also adopt the symlinked node-modules directory structure that pnpm uses (related RFC).
其他
🌐 Others
用 Zig 编写的 Bun 和用 Rust 编写的 Volt 都声称比 npm/Yarn/pnpm 更快。我还没有对这些新的包管理器进行基准测试。
未来计划
🌐 Future Plans
更快、更好、最好。
🌐 Faster, better, best.
