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-catalogs.md
1---2name: pnpm-catalogs3description: Centralized dependency version management for workspaces4---56# pnpm Catalogs78Catalogs provide a centralized way to manage dependency versions across a workspace. Define versions once, use everywhere.910## Basic Usage1112Define a catalog in `pnpm-workspace.yaml`:1314```yaml15packages:16- 'packages/*'1718catalog:19react: ^18.2.020react-dom: ^18.2.021typescript: ~5.3.022vite: ^5.0.023```2425Reference in `package.json` with `catalog:`:2627```json28{29"dependencies": {30"react": "catalog:",31"react-dom": "catalog:"32},33"devDependencies": {34"typescript": "catalog:",35"vite": "catalog:"36}37}38```3940## Named Catalogs4142Create multiple catalogs for different scenarios:4344```yaml45packages:46- 'packages/*'4748# Default catalog49catalog:50lodash: ^4.17.215152# Named catalogs53catalogs:54react17:55react: ^17.0.256react-dom: ^17.0.25758react18:59react: ^18.2.060react-dom: ^18.2.06162testing:63vitest: ^1.0.064"@testing-library/react": ^14.0.065```6667Reference named catalogs:6869```json70{71"dependencies": {72"react": "catalog:react18",73"react-dom": "catalog:react18"74},75"devDependencies": {76"vitest": "catalog:testing"77}78}79```8081## Benefits82831. **Single source of truth**: Update version in one place842. **Consistency**: All packages use the same version853. **Easy upgrades**: Change version once, affects entire workspace864. **Type-safe**: TypeScript support in pnpm-workspace.yaml8788## Catalog vs Overrides8990| Feature | Catalogs | Overrides |91|---------|----------|-----------|92| Purpose | Define versions for direct dependencies | Force versions for any dependency |93| Scope | Direct dependencies only | All dependencies (including transitive) |94| Usage | `"pkg": "catalog:"` | Applied automatically |95| Opt-in | Explicit per package.json | Global to workspace |9697## Publishing with Catalogs9899When publishing, `catalog:` references are replaced with actual versions:100101```json102// Before publish (source)103{104"dependencies": {105"react": "catalog:"106}107}108109// After publish (published package)110{111"dependencies": {112"react": "^18.2.0"113}114}115```116117## Migration from Overrides118119If you're using overrides for version consistency:120121```yaml122# Before (using overrides)123overrides:124react: ^18.2.0125react-dom: ^18.2.0126```127128Migrate to catalogs for cleaner dependency management:129130```yaml131# After (using catalogs)132catalog:133react: ^18.2.0134react-dom: ^18.2.0135```136137Then update package.json files to use `catalog:`.138139## Best Practices1401411. **Use default catalog** for commonly shared dependencies1422. **Use named catalogs** for version variants (e.g., different React versions)1433. **Keep catalog minimal** - only include shared dependencies1444. **Combine with workspace protocol** for internal packages145146```yaml147catalog:148# External shared dependencies149lodash: ^4.17.21150zod: ^3.22.0151152# Internal packages use workspace: protocol instead153# "dependencies": { "@myorg/utils": "workspace:^" }154```155156<!--157Source references:158- https://pnpm.io/catalogs159-->160