pnpm "ERR_PNPM_UNEXPECTED_STORE" - Fix Store Path Mismatch in CI
pnpm links node_modules from a content-addressable store and records which store path it used. ERR_PNPM_UNEXPECTED_STORE means the existing node_modules was built against a different store than the one pnpm now resolves - usually a cache or path change between runs.
What this error means
pnpm install aborts with ERR_PNPM_UNEXPECTED_STORE, reporting that node_modules was created with a different store location. It commonly appears when a restored node_modules cache came from a runner with a different store path.
ERR_PNPM_UNEXPECTED_STORE Unexpected store location
The node_modules was created using a different store path.
Current store: /home/runner/.pnpm-store/v3
Expected store: /root/.pnpm-store/v3Common causes
node_modules restored from a different store path
A cached node_modules built where the pnpm store sat at one path is restored on a runner whose store path differs (different HOME/user), so the recorded store no longer matches.
The store path changed between runs
Changing store-dir, the HOME directory, or the user between runs moves the store, invalidating the link metadata in an existing node_modules.
How to fix it
Reset node_modules and pin the store path
Remove the mismatched node_modules and set a stable store directory.
rm -rf node_modules
pnpm config set store-dir ~/.pnpm-store
pnpm installCache the store, not node_modules
- Cache the pnpm store directory keyed on the lockfile, and let pnpm relink node_modules each run.
- Set a fixed
store-dirso its path does not vary by user/HOME. - Avoid restoring a node_modules built on a differently-pathed store.
How to prevent it
- Pin
store-dirto a stable path. - Cache the pnpm store, not node_modules.
- Keep HOME/user consistent across CI runs.