npm-to-pnpm
npm to pnpm Migration
Overview
Migrate existing npm projects to pnpm. Covers single packages, workspaces/monorepos, CI/CD configuration, and common migration issues.
Current pnpm version: 10.28 (January 2026) - See version_info.md for details.
Quick Start (Single Package)
# 1. Install pnpm
npm install -g pnpm
# 2. Remove npm artifacts
rm package-lock.json
rm -rf node_modules
# 3. Generate pnpm lockfile
pnpm import
# 4. Install dependencies
pnpm install
# 5. Verify
pnpm test && pnpm build
Workflow Decision Tree
Is this a single package or workspace/monorepo?
- Single package: Use
workflow_single_package.md - Workspace/monorepo: Use
workflow_workspace_monorepo.md
Experiencing issues after migration?
- Module not found: See
troubleshooting.md- Module Resolution Issues - Build fails: See
troubleshooting.md- Build and Tooling Issues - CI fails: See
troubleshooting.md- CI/CD Issues - Other issues: See
troubleshooting.md
Need npm command equivalents?
- See
cli_reference.mdfor all command translations
Core Migration Steps
1. Install pnpm
See installation.md for all installation methods. Quick options:
# Via npm
npm install -g pnpm
# Via standalone script (recommended)
curl -fsSL https://get.pnpm.io/install.sh | sh -s -- --version=10.28.0
# Windows PowerShell
iwr https://get.pnpm.io/install.ps1 -useb | iex
2. Convert Lockfile
Use pnpm import to convert package-lock.json or yarn.lock to pnpm-lock.yaml:
pnpm import
See import_command.md for details on import behavior and workspace considerations.
3. Install Dependencies
pnpm install
Key flags:
--frozen-lockfile- CI mode, exact install from lockfile--shamefully-hoist- Temporarily work around module resolution issues--force- Regenerate lockfile from package.json
See install_command.md for full install options.
4. Update Scripts
npm → pnpm command changes:
| npm | pnpm |
|---|---|
npm run <script> |
pnpm <script> or pnpm run <script> |
npm install <pkg> |
pnpm add <pkg> |
npm install -D <pkg> |
pnpm add -D <pkg> |
npm uninstall <pkg> |
pnpm remove <pkg> |
npx <cmd> |
pnpm exec <cmd> or pnpm dlx <cmd> |
See cli_reference.md for complete command reference.
Workspaces and Monorepos
npm workspaces require different handling:
- Create
pnpm-workspace.yamlto define workspace packages - Change workspace dependencies from
*toworkspace:*protocol - Update scripts to use
pnpm -rinstead ofnpm --workspaces
Full guide: workflow_workspace_monorepo.md
Key Differences to Understand
Module Structure
pnpm uses a content-addressable store with symlinks, not a flat node_modules. This:
- Saves disk space (packages stored once globally)
- Creates stricter dependency resolution (reveals hidden dependencies)
- May require explicit dependency declarations
Lockfile
npm ignores package-lock.json. Use pnpm import to convert. After conversion, commit pnpm-lock.yaml to version control.
See limitations.md for details on lockfile differences.
Common Migration Gotchas
Missing Dependencies
Symptom: "Cannot find module" errors after migration
Cause: pnpm's strict layout reveals packages that were "accidentally" available in npm
Solution:
pnpm add <missing-package>
Workspace Protocol
npm: "my-utils": "*"
pnpm: "my-utils": "workspace:*"
Lifecycle Scripts
pnpm may run pre/post scripts differently. If needed:
# .npmrc
enable-pre-post-scripts=true
CI/CD Updates
Update your CI to use pnpm:
GitHub Actions:
- uses: pnpm/action-setup@v4
with:
version: 10.28.0
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
See workflow_single_package.md for more CI examples.
Reference Files Index
Workflow Guides
workflow_single_package.md- Standalone package migrationworkflow_workspace_monorepo.md- Workspace and monorepo migrationtroubleshooting.md- Common issues and solutions
Command Reference
cli_reference.md- npm → pnpm command translationinstall_command.md- Full pnpm install documentationadd_command.md- Dependency adding optionsimport_command.md- Lockfile conversion details
Documentation
version_info.md- Current version (10.28) and installationinstallation.md- All installation methodslimitations.md- Known pnpm limitationsworkspaces.md- Full workspace documentationnpm_vs_pnpm.md- Feature comparisonrelease_10.28.md- Latest release notesreleases.md- Full release history
Configuration (.npmrc)
Common settings for npm migrants:
# Temporary migration aids
shamefully-hoist=true
auto-install-peers=true
# Strictness settings
strict-peer-dependencies=false
enable-pre-post-scripts=true
Migration Checklist
- Install pnpm globally
- Remove
package-lock.json - Run
pnpm import - Run
pnpm install - Verify tests pass
- Verify build succeeds
- Update CI/CD configuration
- Update documentation/README
- Update team on command changes
- Commit
pnpm-lock.yaml
When NOT to Use pnpm
Consider staying with npm if:
- Project relies on npm-specific features (npx quirks, flat modules)
- Legacy tooling with hardcoded node_modules paths
- Strict requirements for npm compatibility
- See
limitations.mdfor full details
More from ghosttypes/ff-5mp-api-ts
typescript-best-practices
TypeScript best practices and patterns for writing type-safe, maintainable code. Use when working with TypeScript files, configuring tsconfig, defining interfaces/types, implementing error handling, writing generics, or setting up type-safe communication patterns. Includes patterns for discriminated unions, type guards, utility types, and more.
34sub-agent-creator
Interactive sub-agent creation skill for Claude Code. Use when user wants to create a custom subagent or mentions needing a specialized agent for specific tasks. This skill guides the entire subagent creation process including identifier design, system prompt generation, skill/context selection, and writing properly formatted agent files to .claude/agents.
12biome
Comprehensive Biome (biomejs.dev) integration for professional TypeScript/JavaScript development. Use for linting, formatting, code quality, and flawless Biome integration into codebases. Covers installation, configuration, migration from ESLint/Prettier, all linter rules, formatter options, CLI usage, editor integration, monorepo setup, and CI/CD integration. Use when working with Biome tooling, configuring biome.json, setting up linting/formatting, migrating projects, debugging Biome issues, or implementing production-ready Biome workflows.
11eslint
Professional-grade ESLint development for JavaScript and TypeScript projects. Use when working with ESLint for (1) configuring ESLint in projects, (2) understanding or fixing ESLint errors and warnings, (3) creating or modifying ESLint rules, (4) integrating ESLint into build systems or editors, (5) migrating ESLint configurations, (6) setting up custom parsers or plugins, (7) troubleshooting ESLint issues, (8) implementing code quality standards, or (9) any task involving ESLint setup, configuration, or usage. Covers all ESLint versions with focus on v9+ flat config format.
10vitest
Comprehensive Vitest testing framework skill for writing, configuring, and running tests in JavaScript/TypeScript projects. Use when Claude needs to: set up Vitest in a new or existing project (Vite or non-Vite), write or modify tests using Vitest APIs, configure Vitest for specific scenarios (coverage, browser testing, mocking, etc.), migrate from Jest or older Vitest versions, debug test failures or configuration issues, implement advanced testing patterns (workspace, browser mode, snapshots, mocking).
10github-actions
Comprehensive GitHub Actions workflow authoring skill. Enables Claude to write production-grade CI/CD workflows with latest best practices, syntax, and security patterns. Use when creating or modifying GitHub Actions workflows, designing CI/CD pipelines, configuring workflow triggers/events/schedules, implementing security patterns (secrets, OIDC, attestations), creating custom actions, migrating from other CI systems, troubleshooting failed workflows, or any GitHub Actions automation task. Includes complete reference documentation extracted from official GitHub docs with source URLs for verification.
10