Subchapter 6.10
references/features-config-dependencies.mdMarkdown3 KBView on GitHub
Config 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.
They live in pnpm-workspace.yaml; their integrity is recorded in a dedicated env-lockfile document inside pnpm-lock.yaml.
configDependencies:
my-configs: "1.0.0"Add one with the --config flag:
pnpm add --config my-configs
pnpm add --config @myorg/pnpm-plugin-my-catalogsdependencies. They may declare optionalDependencies, but only one level deep.preinstall, postinstall, …).optionalDependencies (used for platform-specific binaries, esbuild-style) must use exact versions — ranges/tags are rejected, keeping installs reproducible.A config dependency named pnpm-plugin-*, @*/pnpm-plugin-*, or @pnpm/plugin-* has its pnpmfile.mjs (or .cjs) loaded automatically from the package root.
Because config deps install before the pnpmfile loads, you can import from them:
import { readPackage } from '.pnpm-config/my-hooks'
export const hooks = { readPackage }A plugin can inject settings/catalog entries through the updateConfig hook:
export const hooks = {
updateConfig(config) {
config.catalogs.default ??= {}
config.catalogs.default['is-odd'] = '1.0.0'
return config
}
}After installing it as a config dependency, consumers can use the catalog:
pnpm add is-odd@catalog: # installs is-odd@1.0.0, writes "is-odd": "catalog:"Reference patches stored inside a config dependency:
configDependencies:
my-patches: "1.0.0"
patchedDependencies:
react: "node_modules/.pnpm-config/my-patches/react.patch"configDependencies in pnpm-workspace.yaml; installed before regular deps.optionalDependencies need exact versions.pnpm-plugin-* / @pnpm/plugin-* packages auto-load their pnpmfile.updateConfig hook to push settings/catalogs into consuming projects.