Communityコーディング&開発github.com

antfu/pnpm

厳格な依存関係解決を行うNode.jsパッケージマネージャー。pnpm固有のコマンド実行、ワークスペース設定、カタログ・パッチ・オーバーライドによる依存関係管理に使用します。

pnpm とは?

このSkillは、Node.js向けの高速でディスク効率に優れたパッケージマネージャーであるpnpmを利用するためのものです。従来のnpmやyarnと比較して、pnpmは厳格な依存関係解決と、すべてのパッケージをグローバルに保存してハードリンクする仕組みにより、ディスク容量の節約とインストール速度の向上を実現します。主なユースケースは、pnpm専用のコマンド(例:`pnpm add`、`pnpm run`)の実行、ワークスペース(monorepo)の設定、依存関係のカタログ管理、パッチやオーバーライドの適用です。pnpmの特長であるContent-Addressable Storeにより、異なるプロジェクト間で同じバージョンのパッケージを効率的に共有します。また、`.npmrc`や`pnpm-workspace.yaml`といった設定ファイルを使って詳細な動作をカスタマイズできます。開発者にとって、特に大規模なプロジェクトやmonorepo構成で、依存関係の問題を減らし、開発環境のパフォーマンスを向上させるための強力なツールです。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/antfu/skills/tree/main/skills/pnpm

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

pnpm は何をしますか?

厳格な依存関係解決を行うNode.jsパッケージマネージャー。pnpm固有のコマンド実行、ワークスペース設定、カタログ・パッチ・オーバーライドによる依存関係管理に使用します。

特徴

  • 高速: 並列インストールとキャッシュにより、パッケージのインストールが高速です。
  • ディスク効率: すべてのパッケージをグローバルストアに保存し、プロジェクト間でハードリンクすることでディスク容量を節約します。
  • 厳格な依存関係: node_modulesの構造を厳密に管理し、依存関係の重複や衝突を防止します。
  • ワークスペース対応: pnpm-workspace.yamlを使ってmonorepo構成を簡単に管理できます。

インストール

npm install -g pnpm

または、corepackを使用する場合:

corepack enable
corepack prepare pnpm@latest --activate

基本的な使い方

パッケージのインストール

pnpm add <package-name>
pnpm add -D <dev-dependency>
pnpm add --global <global-package>

スクリプトの実行

pnpm run <script-name>
pnpm test
pnpm build

依存関係の更新

pnpm update
pnpm update <package-name>

ワークスペース (monorepo)

pnpm-workspace.yaml ファイルでワークスペースを定義します:

packages:
  - 'packages/*'
  - 'apps/*'

ワークスペース内のパッケージに対してコマンドを実行するには:

pnpm --filter <package-name> run build
pnpm --filter "./packages/**" test

設定

プロジェクトの.npmrcファイルでpnpmの動作をカスタマイズできます:

# インストール時にダウンロードの進捗を表示しない
loglevel=warn

# 自動でlockfileを更新しない
lockfile=false

# 指定したパッケージの更新を許可しない
frozen-lockfile=true

カタログ

依存関係のバージョンを一元管理するために、pnpm-workspace.yaml内でcatalogsセクションを使用できます:

catalogs:
  default:
    react: ^18.2.0
    typescript: ^5.0.0

パッチ

依存関係にパッチを適用するには、patchesディレクトリにパッチファイルを配置し、package.jsonのpnpm.patchedDependenciesフィールドに追加します:

{
  "pnpm": {
    "patchedDependencies": {
      "[email protected]": "patches/[email protected]"
    }
  }
}

オーバーライド

依存関係のバージョンを強制的に変更するには、package.jsonのpnpm.overridesフィールドを使用します:

{
  "pnpm": {
    "overrides": {
      "lodash": "^4.17.21",
      "react": { ".": "^18.2.0" }
    }
  }
}

関連リソース

Individual skills in this repo

This repo contains 16 individual skills — each has its own dedicated page.

antfu/antfu

Anthony Fu's opinionated tooling and conventions for JavaScript/TypeScript projects. Use when setting up new projects, configuring ESLint/Prettier alternatives, monorepos, library publishing, or when the user mentions Anthony Fu's preferences.

antfu/nuxt

Nuxt full-stack Vue framework with SSR, auto-imports, and file-based routing. Use when working with Nuxt apps, server routes, useFetch, middleware, or hybrid rendering.

antfu/pinia

Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.

antfu/slidev

Create and present web-based slidedecks for developers using Slidev with Markdown, Vue components, code highlighting, animations, and interactive features. Use when building technical presentations, conference talks, code walkthroughs, teaching materials, or developer decks.

antfu/tsdown

Bundle TypeScript and JavaScript libraries with blazing-fast speed powered by Rolldown. Use when building libraries, generating type declarations, bundling for multiple formats, or migrating from tsup.

antfu/turborepo

Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when user: configures tasks/workflows/pipelines, creates packages, sets up monorepo, shares code between apps, runs changed/affected packages, debugs cache, or has apps/packages directories.

antfu/unocss

UnoCSS instant atomic CSS engine, superset of Tailwind CSS. Use when configuring UnoCSS, writing utility rules, shortcuts, or working with presets like Wind, Icons, Attributify.

antfu/vite

Vite build tool configuration, plugin API, SSR, and Vite 8 Rolldown migration. Use when working with Vite projects, vite.config.ts, Vite plugins, or building libraries/SSR apps with Vite.

antfu/vitepress

VitePress static site generator powered by Vite and Vue. Use when building documentation sites, configuring themes, or writing Markdown with Vue components.

antfu/vitest

Vitest fast unit testing framework powered by Vite with Jest-compatible API. Use when writing tests, mocking, configuring coverage, or working with test filtering and fixtures.

antfu/vue

Vue 3 Composition API, script setup macros, reactivity system, and built-in components. Use when writing Vue SFCs, defineProps/defineEmits/defineModel, watchers, or using Transition/Teleport/Suspense/KeepAlive.

antfu/vue-best-practices

MUST be used for Vue.js tasks. Strongly recommends Composition API with `<script setup>` and TypeScript as the standard approach. Covers Vue 3, SSR, Volar, vue-tsc. Load for any Vue, .vue files, Vue Router, Pinia, or Vite with Vue work. ALWAYS use Composition API unless the project explicitly requires Options API.

antfu/vue-router-best-practices

Vue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.

antfu/vue-testing-best-practices

Use for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.

antfu/vueuse-functions

Apply VueUse composables where appropriate to build concise, maintainable Vue.js / Nuxt features.

antfu/web-design-guidelines

Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

関連スキル