功能比较
功能 | pnpm | Yarn | npm | 备注 |
---|---|---|---|---|
Workspace support | ✅ | ✅ | ✅ | |
隔离的 node_modules | ✅ | ✅ | ✅ | pnpm 中的默认值。 |
Hoisted node_modules | ✅ | ✅ | ✅ | npm 中的默认值。 |
Plug'n'Play | ✅ | ✅ | ❌ | Yarn 中的默认值。 |
Autoinstalling peers | ✅ | ❌ | ✅ | |
零安装 | ❌ | ✅ | ❌ | |
Patching dependencies | ✅ | ✅ | ❌ | |
Managing Node.js versions | ✅ | ❌ | ❌ | |
Managing versions of itself | ✅ | ✅ | ❌ | |
拥有锁文件 | ✅ | ✅ | ✅ | pnpm-lock.yaml , yarn.lock , package-lock.json . |
Overrides support | ✅ | ✅ | ✅ | 在 Yarn 中称为“resolutions”。 |
内容可寻址存储 | ✅ | ✅ | ❌ | Yarn uses a CAS when nodeLinker is set to pnpm . |
Dynamic package execution | ✅ | ✅ | ✅ | pnpm dlx , yarn dlx , npx . |
Side-effects cache | ✅ | ❌ | ❌ | |
Catalogs | ✅ | ❌ | ❌ | |
Config dependencies | ✅ | ❌ | ❌ | |
JSR registry support | ✅ | ✅ | ❌ | |
Auto-install before script run | ✅ | ❌ | ❌ | 依赖项在 Yarn 中,即插即用(Plug'n'Play)可确保依赖项始终保持最新。 |
Hooks | ✅ | ✅ | ❌ | |
Listing licenses | ✅ | ✅ | ❌ | pnpm supports it via pnpm licenses list . Yarn 有一个插件来支持这个功能。 |
Note: To keep the comparison concise, we include only features likely to be used frequently.