功能对比
| Feature | pnpm | npm | Notes |
|---|---|---|---|
| Workspace support | ✅ | ✅ | |
Isolated node_modules | ✅ | ✅ | pnpm 中的默认行为。 |
| Hoisted node_modules | ✅ | ✅ | npm 中的默认行为。 |
| Plug'n'Play | ✅ | ❌ | |
| Autoinstalling peers | ✅ | ✅ | |
| Patching dependencies | ✅ | ❌ | |
| Managing runtimes | ✅ | ❌ | |
| Managing versions of itself | ✅ | ❌ | |
| 有锁文件 | ✅ | ✅ | pnpm-lock.yaml, package-lock.json. |
| Overrides support | ✅ | ✅ | |
| 内容寻址存储 | ✅ | ❌ | |
| Dynamic package execution | ✅ | ✅ | pnx, npx. |
| Side-effects cache | ✅ | ❌ | |
| Catalogs | ✅ | ❌ | |
| Config dependencies | ✅ | ❌ | |
| JSR registry support | ✅ | ❌ | |
| Auto-install before script run | ✅ | ❌ | |
| Hooks | ✅ | ❌ | |
| Build script security | ✅ | ❌ | |
| SBOM generation | ✅ | ✅ | pnpm sbom, npm sbom. |
| Listing licenses | ✅ | ❌ | pnpm 通过 pnpm licenses list 支持它。 |
**注意:**为了保持对比简洁,我们只包含可能经常使用的功能。
本页内容译自pnpm 官方文档(MIT License),如有出入以英文原文为准。