Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
pnpm 10.x reference skill covering workspaces, catalogs, patches, peer deps, overrides, and CI/CD caching strategies.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/features-config-dependencies.md
1---2name: pnpm-config-dependencies3description: Share and centralize pnpm hooks, settings, patches, catalogs, and overrides across repos via config dependencies4---56# pnpm Config Dependencies78Config dependencies are npm packages that pnpm installs **before** all regular dependencies, so they can supply hooks, settings, patches, catalogs, and overrides that are reused across many repositories. They let you keep one shared "pnpm config" package and consume it everywhere.910## Declaring config dependencies1112They live in `pnpm-workspace.yaml`; their integrity is recorded in a dedicated env-lockfile document inside `pnpm-lock.yaml`.1314```yaml title="pnpm-workspace.yaml"15configDependencies:16my-configs: "1.0.0"17```1819Add one with the `--config` flag:2021```bash22pnpm add --config my-configs23pnpm add --config @myorg/pnpm-plugin-my-catalogs24```2526## Constraints2728- **No regular `dependencies`.** They may declare `optionalDependencies`, but only one level deep.29- **No lifecycle scripts** (`preinstall`, `postinstall`, …).30- `optionalDependencies` (used for platform-specific binaries, esbuild-style) must use **exact** versions — ranges/tags are rejected, keeping installs reproducible.3132## Auto-loaded plugins3334A config dependency named `pnpm-plugin-*`, `@*/pnpm-plugin-*`, or `@pnpm/plugin-*` has its `pnpmfile.mjs` (or `.cjs`) loaded automatically from the package root.3536## Use cases3738### Import hook logic from a shared package3940Because config deps install before the pnpmfile loads, you can import from them:4142```js title=".pnpmfile.mjs"43import { readPackage } from '.pnpm-config/my-hooks'4445export const hooks = { readPackage }46```4748### Share settings & catalogs via updateConfig4950A plugin can inject settings/catalog entries through the `updateConfig` hook:5152```js title="@myorg/pnpm-plugin-my-catalogs/pnpmfile.mjs"53export const hooks = {54updateConfig(config) {55config.catalogs.default ??= {}56config.catalogs.default['is-odd'] = '1.0.0'57return config58}59}60```6162After installing it as a config dependency, consumers can use the catalog:6364```bash65pnpm add is-odd@catalog: # installs [email protected], writes "is-odd": "catalog:"66```6768### Share patch files6970Reference patches stored inside a config dependency:7172```yaml title="pnpm-workspace.yaml"73configDependencies:74my-patches: "1.0.0"75patchedDependencies:76react: "node_modules/.pnpm-config/my-patches/react.patch"77```7879## Key Points8081- Centralize hooks, settings, catalogs, overrides, and patches in one package, consumed across repos.82- Declared via `configDependencies` in `pnpm-workspace.yaml`; installed before regular deps.83- No regular dependencies and no lifecycle scripts; `optionalDependencies` need exact versions.84- `pnpm-plugin-*` / `@pnpm/plugin-*` packages auto-load their pnpmfile.85- Pair with the `updateConfig` hook to push settings/catalogs into consuming projects.8687<!--88Source references:89- https://pnpm.io/config-dependencies90- https://pnpm.io/pnpmfile#hooksupdateconfigconfig-config--promiseconfig91-->92