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/core-store.md
1---2name: pnpm-store3description: Content-addressable storage system that makes pnpm fast and disk-efficient4---56# pnpm Store78pnpm uses a content-addressable store to save disk space and speed up installations. All packages are stored once globally and hard-linked to project `node_modules`.910## How It Works11121. **Global Store**: Packages are downloaded once to a central store132. **Hard Links**: Projects link to store instead of copying files143. **Content-Addressable**: Files are stored by content hash, deduplicating identical files1516### Storage Layout1718```19~/.pnpm-store/ # Global store (default location)20└── v3/21└── files/22└── <hash>/ # Files stored by content hash2324project/25└── node_modules/26├── .pnpm/ # Virtual store (hard links to global store)27│ ├── [email protected]/28│ │ └── node_modules/29│ │ └── lodash/30│ └── [email protected]/31│ └── node_modules/32│ ├── express/33│ └── <deps>/ # Flat structure for dependencies34├── lodash -> .pnpm/[email protected]/node_modules/lodash35└── express -> .pnpm/[email protected]/node_modules/express36```3738## Store Commands3940```bash41# Show store location42pnpm store path4344# Remove unreferenced packages45pnpm store prune4647# Check store integrity48pnpm store status4950# Add package to store without installing51pnpm store add <pkg>52```5354## Configuration5556### Store Location5758```ini59# .npmrc60store-dir=~/.pnpm-store6162# Or use environment variable63PNPM_HOME=~/.local/share/pnpm64```6566### Virtual Store6768The virtual store (`.pnpm` in `node_modules`) contains symlinks to the global store:6970```ini71# Customize virtual store location72virtual-store-dir=node_modules/.pnpm7374# Alternative flat layout75node-linker=hoisted76```7778## Disk Space Benefits7980pnpm saves significant disk space:8182- **Deduplication**: Same package version stored once across all projects83- **Content deduplication**: Identical files across different packages stored once84- **Hard links**: No copying, just linking8586### Check disk usage8788```bash89# Compare actual vs apparent size90du -sh node_modules # Apparent size91du -sh --apparent-size node_modules # With hard links counted92```9394## Node Linker Modes9596Configure how `node_modules` is structured:9798```ini99# Default: Symlinked structure (recommended)100node-linker=isolated101102# Flat node_modules (npm-like, for compatibility)103node-linker=hoisted104105# PnP mode (experimental, like Yarn PnP)106node-linker=pnp107```108109### Isolated Mode (Default)110111- Strict dependency resolution112- No phantom dependencies113- Packages can only access declared dependencies114115### Hoisted Mode116117- Flat `node_modules` like npm118- For compatibility with tools that don't support symlinks119- Loses strictness benefits120121## Side Effects Cache122123Cache build outputs for native modules:124125```ini126# Enable side effects caching127side-effects-cache=true128129# Store side effects in project (instead of global store)130side-effects-cache-readonly=true131```132133## Shared Store Across Machines134135For CI/CD, you can share the store:136137```yaml138# GitHub Actions example139- uses: pnpm/action-setup@v4140with:141run_install: false142143- name: Get pnpm store directory144shell: bash145run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV146147- uses: actions/cache@v4148with:149path: ${{ env.STORE_PATH }}150key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}151```152153## Troubleshooting154155### Store corruption156```bash157# Verify and fix store158pnpm store status159pnpm store prune160```161162### Hard link issues (network drives, Docker)163```ini164# Use copying instead of hard links165package-import-method=copy166```167168### Permission issues169```bash170# Fix store permissions171chmod -R u+w ~/.pnpm-store172```173174<!--175Source references:176- https://pnpm.io/symlinked-node-modules-structure177- https://pnpm.io/cli/store178- https://pnpm.io/npmrc#store-dir179-->180