功能比较
功能 | pnpm | Yarn | npm | Notes |
---|---|---|---|---|
工作空间支持 | ✅ | ✅ | ✅ | |
隔离的 node_modules | ✅ | ✅ | ✅ | Default in pnpm. |
提升的 node_modules | ✅ | ✅ | ✅ | Default in npm. |
Plug'n'Play | ✅ | ✅ | ❌ | Default in Yarn. |
自动安装对等依赖 | ✅ | ❌ | ✅ | |
零安装 | ❌ | ✅ | ❌ | |
修补依赖项 | ✅ | ✅ | ❌ | |
管理 Node.js 版本 | ✅ | ❌ | ❌ | |
Managing versions of itself | ✅ | ✅ | ❌ | |
拥有锁文件 | ✅ | ✅ | ✅ | pnpm-lock.yaml , yarn.lock , package-lock.json . |
支持覆盖 | ✅ | ✅ | ✅ | Known as "resolutions" in Yarn. |
内容可寻址存储 | ✅ | ✅ | ❌ | Yarn uses a CAS when nodeLinker is set to pnpm . |
动态包执行 | ✅ | ✅ | ✅ | pnpm dlx , yarn dlx , npx . |
副作用缓存 | ✅ | ❌ | ❌ | |
Catalogs | ✅ | ❌ | ❌ | |
Config dependencies | ✅ | ❌ | ❌ | |
JSR registry support | ✅ | ✅ | ❌ | |
Auto-install before script run | ✅ | ❌ | ❌ | In Yarn, Plug'n'Play ensures dependencies are always up to date. |
钩子 | ✅ | ✅ | ❌ | |
列出许可证 | ✅ | ✅ | ❌ | pnpm supports it via pnpm licenses list . Yarn has a plugin for it. |
Note: To keep the comparison concise, we include only features likely to be used frequently.