pnpm/pnpm · error · LinkPhaseError
Missing CAS paths for required package
Error message
Missing CAS paths for required package {pkg_id_with_patch_hash:?} at {dir:?} What it means
Raised by the hoisted-modules linker (LinkHoistedModulesError, surfaced as the LinkHoistedModules variant of LinkPhaseError). While materializing the hoisted node_modules hierarchy, a package snapshot that must be linked has no CAS (content-addressable store) paths registered for it. The linker cannot produce hard links/copies from the store because the package's files are missing from the index it was given - an internal consistency violation between the resolution graph and the store data.
Solutions
- Repopulate the store for the project: delete node_modules and reinstall so missing packages are fetched again.
- Run a store verification/prune against the store directory and then reinstall if it reports missing or orphaned entries.
- If using pnpm patches, remove and re-add the patch so the patched snapshot and its store entry agree.
- Point the project at a healthy local store (store-dir) rather than a network/shared mount that lost files.
- Report a bug if a normal install reproduces it - the graph and store data should never disagree.
Example fix
// before: store entry missing for patched package $ pnpm install Missing CAS paths for required package "lodash@4.17.21+patch_hash=abc123" at ... // after $ rm -rf node_modules && pnpm install
Defensive patterns
Strategy: retry
Validate before calling
# Verify the store contains the packages the lockfile needs before reinstalling pnpm store status || echo "store is missing entries; expect a full re-fetch"
Prevention
- Avoid running pnpm store prune while other installs are in flight against the same store.
- Keep the store directory on a reliable local disk, not a network share.
- After changing pnpm patches, reinstall so patched snapshots are re-fetched.
- Use a single pinned pnpm version per project so patch hashes stay stable.
When it happens
Trigger: Running the hoisted linker (node-linker=hoisted or the hoisted install path) when the store index lacks entries for a required package id (including its patch hash): the store was pruned or deleted mid-flight, a patch hash changed but the store entry was not fetched, or the packages map passed into the phase is incomplete.
Common situations: Shared store corrupted by pnpm store prune while another project installs; interrupted fetch left the package absent; switching pnpm versions where the patch hash computation changed; mounted store on a network drive with lost files.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- CreateVirtualDir(#[error(source)] CreateVirtualDirError)
- FROZEN_STORE_NEEDS_BUILD
- HoistedDepGraph(#[error(source)]…
- HoistLinkBins(#[error(source)] LinkBinsError)
- HoistLinkBins(#[error(source)] pnpm_cmd_shim::LinkBinsError)
AI-assisted analysis of pnpm/pnpm@e45f033222 (2026-09-22).
Data as JSON: /api/errors/d4e541ae90e24c99.
Report an issue: GitHub.
Appendix: source
Thrown at pnpm/crates/deps-restorer/src/linking.rs:57
pub enum LinkPhaseError {
#[diagnostic(transparent)]
PruneStaleModules(#[error(source)] crate::PruneDirectDepsError),
#[diagnostic(transparent)]
SymlinkDirectDependencies(#[error(source)] crate::SymlinkDirectDependenciesError),
#[diagnostic(transparent)]
LinkRootComponentMembers(#[error(source)] crate::LinkRootComponentMembersError),
#[diagnostic(transparent)]
LinkVirtualStoreBins(#[error(source)] crate::LinkVirtualStoreBinsError),
#[diagnostic(transparent)]
HoistSymlink(#[error(source)] crate::SymlinkPackageError),
#[diagnostic(transparent)]
HoistLinkBins(#[error(source)] pnpm_cmd_shim::LinkBinsError),
#[diagnostic(transparent)]
LinkBins(#[error(source)] pnpm_cmd_shim::LinkBinsError),
#[diagnostic(transparent)]
HoistedDepGraph(#[error(source)] crate::HoistedDepGraphError),
#[diagnostic(transparent)]
LinkHoistedModules(#[error(source)] crate::LinkHoistedModulesError),
#[display("failed to write package map: {_0}")]
#[diagnostic(code(ERR_PNPM_PACKAGE_MANAGER_WRITE_PACKAGE_MAP))]
WritePackageMap(#[error(source)] crate::WritePackageMapError),
#[display("failed to write PnP loader: {_0}")]
#[diagnostic(code(ERR_PNPM_PACKAGE_MANAGER_WRITE_PNP_FILE))]
WritePnpFile(#[error(source)] crate::WritePnpFileError),
}
impl From<HoistedLinkerError> for LinkPhaseError {
fn from(error: HoistedLinkerError) -> Self {
match error {
HoistedLinkerError::HoistedDepGraph(error) => LinkPhaseError::HoistedDepGraph(error),
HoistedLinkerError::LinkHoistedModules(error) => {
LinkPhaseError::LinkHoistedModules(error)
}
HoistedLinkerError::SymlinkDirectDependencies(error) => {
LinkPhaseError::SymlinkDirectDependencies(error)
}View on GitHub (pinned to e45f033222)