How to Fix pnpm Install Errors
In this tutorial, you'll learn about How to Fix pnpm Install Errors. We cover key concepts, practical examples, and best practices.
The Problem
pnpm install fails with Error: Cannot find matching keyid or ERR_PNPM_PEER_DEP_MISSING or Lockfile is not up-to-date. pnpm uses a content-addressable store and strict dependency resolution that differ significantly from npm and Yarn. The store can become corrupted, the lockfile can drift from package.json, and peer dependency conflicts are enforced more strictly by default. pnpm also validates package integrity using checksums, and a mismatch between the lockfile and the registry causes a "matching keyid" error.
Quick Fix
1. Clear the pnpm store, prune dead packages, and reinstall
pnpm store prune
rm -rf node_modules
pnpm install
Expected output:
Packages: +1420
++++++++++++++++++++++++++++++++++++++++
Progress: resolved 1420, reused 1380, downloaded 40, added 1420
Done in 8.2s
The store prune command removes unreferenced packages from the content-addressable store, freeing disk space and resolving checksum corruption.
2. Fix lockfile staleness
If you get Lockfile is not up-to-date:
pnpm install --frozen-lockfile
If that fails, the lockfile needs updating to match package.json. Update it:
pnpm install --no-frozen-lockfile
git add pnpm-lock.yaml
git commit -m "Update pnpm lockfile"
3. Relax strict peer dependency checking
pnpm enforces peer dependency requirements more strictly than npm. In .npmrc at the project root:
strict-peer-dependencies=false
auto-install-peers=true
Then reinstall:
pnpm install
Expected output:
Already up to date (or downloaded new packages)
Done in 1.2s
4. Verify and repair the content-addressable store
pnpm store status
Expected output (healthy):
Store path: /home/user/.local/share/pnpm/store/v3
No broken packages found
If the store is corrupted:
pnpm store prune
pnpm install --force
5. Fix network timeout issues
Slow networks cause pnpm to fail with fetch timeouts. In .npmrc:
fetch-timeout=120000
fetch-retries=5
fetch-retry-maxtimeout=120000
network-concurrency=3
6. Use a mirror registry if the default registry is slow
In .npmrc:
registry=https://registry.npmmirror.com
Or temporarily:
pnpm install --registry=https://registry.npmmirror.com
7. Verify the final installation
pnpm ls --depth=0
Expected output:
dependencies:
express 4.18.2
react 18.2.0
react-dom 18.2.0
typescript 5.3.3
8. Check for Node.js version incompatibility
node --version
pnpm --version
If pnpm expects a newer Node.js version than installed, you see:
ERROR: Unsupported Node.js version.
Upgrade Node.js via nvm:
nvm install 20
nvm use 20
9. Use pnpm overrides to fix dependency version conflicts
{
"pnpm": {
"overrides": {
"react": "^18.2.0",
"typescript": "~5.3.0"
}
}
}
Overrides force all sub-dependencies to use the specified version.
Prevention
- Keep
pnpm-lock.yamlcommitted to version control at all times — never add it to.gitignore - Run
pnpm store pruneperiodically, especially on CI runners with limited disk space - Use
pnpm install --frozen-lockfilein CI to catch lockfile drift early and fail fast - Set
auto-install-peers=truein.npmrcto automatically install missing peer dependencies - Pin the pnpm version in
package.jsonusing thepackageManagerfield:"packageManager": "pnpm@8.15.0"
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro