pnpm vs Bun: CI にはどちらの高速パッケージマネージャを選ぶか
どちらも npm に対する高速な代替ですが、pnpm は純粋にパッケージマネージャである一方、Bun は install をオールインワンの runtime に束ねています。
pnpm はコンテンツアドレス方式の store と厳格な解決を備えた、高速でディスク効率の良いパッケージマネージャです。Bun はオールインワンの JavaScript ツールキットで、そのインストーラ(bun install)は生の速度に最適化されています。
| pnpm | Bun | |
|---|---|---|
| スコープ | パッケージマネージャ | Runtime + インストーラ + test + bundler |
| インストール速度 | 非常に高速 | 非常に高速 |
| Lockfile | pnpm-lock.yaml | bun.lock (テキスト) / bun.lockb |
| CI での install | pnpm install --frozen-lockfile | bun install --frozen-lockfile |
| エコシステム互換性 | 普遍的 (Node) | 高い、まれにエッジケース |
CI において
どちらも npm に比べて install 時間を大幅に削減します。pnpm は標準の Node 上で動作する用途を絞ったパッケージマネージャなので、高速な install だけが欲しいときの安全な選択です。Bun は依存関係を install でき、さらに自身の高速な runtime で tests/builds も実行できてツールチェーンを簡素化しますが、一部のネイティブや postinstall の重いパッケージはときに Node へのフォールバックを必要とします。
パイプライン向けの選択
Node に留まりながら高速な install が欲しいなら pnpm。検証済みの install、test、run のための一つの高速ツールキットが欲しいなら Bun。どちらでも lockfile を commit し frozen フラグを使い、繰り返しの install を減らすために store を cache してください。
Decide with your own numbers, not a feature table
Feature comparisons age badly and rarely decide anything, because both tools in a mature category can do the job. What differs is how each behaves on your repository, and that takes one afternoon to measure.
# time a cold install with each candidate, cache cleared
hyperfine --prepare "rm -rf node_modules" --warmup 1 \
"<tool-a> install" "<tool-b> install"
# and the thing CI actually pays for: a cold run with no local cache
docker run --rm -v "$(pwd):/w" -w /w node:22 sh -c "<tool> install"What actually changes when you switch
- Lockfile format. A switch is a one-way door for anyone still on the old tool until everyone migrates, so plan it as a single coordinated change.
- Resolution strictness. Tools differ on whether an undeclared transitive import works, and the stricter one will surface latent bugs as new failures.
- CI cache configuration. The cache path and key differ per tool; carrying over the old ones silently disables caching.
- Everyone on the team and every runner must move together. Pin the version so they cannot drift.
結論
Node に留まり高速な install だけが欲しいなら pnpm。オールインワンの高速ツールチェーンのために Bun の runtime を採用してもよいなら Bun。コミットする前に、Bun の下で依存関係ツリー全体を検証してください。