Pnpm Workspace
This skill teaches you how to build and manage pnpm workspaces, enabling efficient monorepo development across multiple interconnected packages. You'll master workspace configuration, dependency management, and best practices for scaling projects with pnpm's lightweight approach.
Pnpm Workspace enables you to manage multiple packages within a single repository using pnpm's efficient monorepo approach. Start by creating a pnpm-workspace.yaml file at your repository root that defines which directories contain packages (typically using glob patterns like 'packages/*'). Then run pnpm install to link all packages together. Pnpm automatically handles dependency hoisting and creates symbolic links between local packages, allowing them to reference each other as if they were published on npm.
AI-generated summary based on this skill's SKILL.md
Install
oakoss/agent-skills/pnpm-workspace · repository language: Python
git clone https://github.com/oakoss/agent-skills
cp -r agent-skills ~/.claude/skills/pnpm-workspacegenerated, unverified - the skill's exact subdirectory could not be determined; check the repository on GitHub
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I use pnpm workspaces?
Pnpm Workspace enables you to manage multiple packages within a single repository using pnpm's efficient monorepo approach. Start by creating a pnpm-workspace.yaml file at your repository root that defines which directories contain packages (typically using glob patterns like 'packages/*'). Then run pnpm install to link all packages together. Pnpm automatically handles dependency hoisting and creates symbolic links between local packages, allowing them to reference each other as if they were published on npm.
What is pnpm workspace setup and how do I configure it?
Pnpm Workspace setup begins with creating a pnpm-workspace.yaml configuration file that specifies your workspace structure. Define package locations using glob patterns—for example, packages/* for all subdirectories in a packages folder. You can also exclude specific directories with negation patterns. Once configured, Pnpm Workspace manages your monorepo's dependency resolution, ensuring that internal package references are resolved locally while external dependencies are deduplicated across the workspace, saving disk space and improving installation speed.
How do I organize projects with pnpm and manage dependencies across packages?
Pnpm Workspace allows you to organize projects by defining multiple packages in your pnpm-workspace.yaml file. Each package maintains its own package.json with dependencies. Pnpm Workspace automatically links local packages together, so when package-a depends on package-b (both in your workspace), Pnpm Workspace creates a symbolic link instead of downloading from npm. Use pnpm add to install dependencies, and pnpm Workspace will intelligently determine whether to link locally or fetch from the registry. This structure scales efficiently as your monorepo grows.
What are the best practices for pnpm workspace configuration?
Pnpm Workspace best practices include organizing packages into logical directories (commonly 'packages/' for libraries and 'apps/' for applications), using consistent versioning strategies across related packages, and leveraging pnpm's filtering commands to run scripts across specific packages. Keep your pnpm-workspace.yaml simple and maintainable. Use .npmrc files to configure workspace-wide settings. Pnpm Workspace's hoisting mechanism automatically optimizes your node_modules structure, but you should still review your dependency declarations to avoid circular dependencies and ensure clear package boundaries.
How do pnpm workspace commands help manage multiple packages?
Pnpm Workspace provides powerful commands for managing multiple packages efficiently. Use pnpm -r (recursive) to run scripts across all packages, or combine it with --filter to target specific packages. The pnpm list command shows your workspace structure, while pnpm install handles dependency resolution across the entire workspace. Pnpm Workspace's filtering syntax lets you run commands on packages matching certain criteria, making it easy to build, test, or deploy subsets of your monorepo without affecting unrelated packages.
How do I troubleshoot pnpm workspace configuration and package resolution issues?
When troubleshooting Pnpm Workspace issues, first verify your pnpm-workspace.yaml syntax and ensure glob patterns correctly match your package directories. Run pnpm list to inspect the workspace structure and confirm all packages are recognized. Check that each package has a valid package.json with a unique name field. If packages aren't linking correctly, clear your node_modules and .pnpm-store, then run pnpm install fresh. Use pnpm why to trace dependency resolution, and review .npmrc settings that might affect workspace behavior. Pnpm Workspace's strict resolution can help catch configuration errors early.