Pnpm

From G1Joshi/Agent-Skills · View interactive version

Pnpm is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert pnpm fast, disk-efficient package manager assistance covering hard links, symlinks, pnpm-workspace.yaml, and monorepos. Use when managing JavaScript/TypeScript packages with speed and zero duplication.

How to use this skill

Skill file

pnpm

pnpm is a fast, disk-efficient package manager for JavaScript that uses a content-addressable store and symlinked node_modules to eliminate duplicate dependencies across projects.

When to Use

Quick Start

# Enable via Corepack
corepack enable
corepack prepare pnpm@latest --activate

pnpm add next

Core Concepts

Configuring Monorepo Workspaces (pnpm-workspace.yaml)

Declaring workspace packages and root settings:

# pnpm-workspace.yaml
packages:
  - "packages/*"
  - "apps/*"
  - "!**/test/**"
// packages/core-service/package.json
{
  "name": "@my-org/core-service",
  "version": "1.0.0",
  "dependencies": {
    "@my-org/shared-utils": "workspace:*" // Symlinks to local workspace package
  }
}

Workspace Commands & Parallel Script Execution

Running builds and tests across packages:

# Run tests in parallel across all workspace packages
pnpm --recursive run test

# Run build only for packages modified since main branch
pnpm --filter "...[origin/main]" run build

# Install a shared dependency to a specific package
pnpm --filter @my-org/web-app add lucide-react

Hard Links and Content-Addressable Store

Inspecting and pruning global package deduplication:

# Verify integrity of global content-addressable store
pnpm store status

# Clean up unreferenced packages to free disk space
pnpm store prune

Common Patterns

Monorepo Workspaces with Shared Internal Packages

Problem: Inefficient symlinking and phantom dependency hoisting in large JavaScript monorepos.

Solution:

Define clean workspace structure in pnpm-workspace.yaml:

packages:
  - "apps/*"
  - "packages/*"

Consume internal package with workspace:* protocol:

{
  "dependencies": {
    "@myorg/ui": "workspace:*",
    "@myorg/utils": "workspace:*"
  }
}

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :-------------------------------------------------- | :--------------------------------------------------------------------------------- | :--------------------------------------------------------------------- |

| ERR_PNPM_PEER_DEP_ISSUES: Unmet peer dependencies | Strict peer dependency resolution blocking install. | Configure .npmrc with auto-install-peers=true or resolve versions. |

| Cannot find module ... (phantom dependency) | Package relies on a transitive dependency not explicitly declared in package.json. | Explicitly add the missing package to package.json dependencies. |

| pnpm-lock.yaml out of date | Running pnpm install --frozen-lockfile after package.json was modified. | Run pnpm install locally to update lockfile and commit changes. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.