pnpm/pnpm · error · PnpmError
MISSING_PACKAGE_INDEX_FILE
MISSING_PACKAGE_INDEX_FILE
Error message
Failed to find package index file for ${pkg.id} (at ${err.path}), please consider running 'pnpm install' What it means
Thrown by the license scanner when readPackageFileMap() fails with ENOENT while looking up the package's index file in the store. The index maps package files to content-addressable store paths; its absence means the package was never materialized by an install with this store — typically a missing or partial install.
Source
Thrown at pnpm11/deps/compliance/license-scanner/src/getPkgInfo.ts:83
packageResolution,
pkg.id,
{
storeDir: opts.storeDir,
storeIndex: opts.storeIndex,
lockfileDir: opts.dir,
virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,
}
)
if (!result) {
throw new PnpmError(
'UNSUPPORTED_PACKAGE_TYPE',
`Unsupported package resolution type for ${pkg.id}`
)
}
files = result
} catch (err: any) { // eslint-disable-line
if (err.code === 'ENOENT') {
throw new PnpmError(
'MISSING_PACKAGE_INDEX_FILE',
`Failed to find package index file for ${pkg.id} (at ${err.path}), please consider running 'pnpm install'`
)
}
throw err
}
const manifestPath = files.get('package.json')
if (!manifestPath) {
throw new PnpmError(
'MISSING_PACKAGE_INDEX_FILE',
`Failed to find package.json in index for ${pkg.id}, please consider running 'pnpm install'`
)
}
const manifest = await readPackageJson(manifestPath)
// Determine the path to the package as known by the user
const modulesDir = opts.modulesDir ?? 'node_modules'View on GitHub (pinned to 5b11d3a15b)
Solutions
- Run `pnpm install` (as the message suggests) so the store index entries exist
- Verify the store location is stable (no changing store-dir config) between install and licenses commands
- If using a shared/CI cache, ensure it caches the store index files, not just node_modules
Example fix
// before $ pnpm install --lockfile-only && pnpm licenses list // after $ pnpm install && pnpm licenses list
Defensive patterns
Strategy: try-catch
Try / catch
try {
return await getPkgInfo(pkg, opts)
} catch (err) {
if (err instanceof PnpmError && err.code === 'MISSING_PACKAGE_INDEX_FILE' && /index file/.test(err.message)) {
await runInstall() // then retry once
return getPkgInfo(pkg, opts)
}
throw err
} Prevention
- Never scan licenses after a --lockfile-only install; run a full install first
- Keep store-dir configuration identical between the install and the scan steps
- Avoid pruning the store between install and licenses commands
When it happens
Trigger: Running `pnpm licenses list` after `pnpm install --lockfile-only`; a pruned or shared store where the index for that package id was removed; a store directory that changed location between install and scan.
Common situations: CI pipelines that skip full installs for speed; `pnpm store prune` run between install and licenses scan; node_modules deleted but lockfile kept.
Related errors
- FROZEN_STORE_NEEDS_BUILD
- UNSUPPORTED_PACKAGE_TYPE
- NO_OFFLINE_TARBALL
- NO_PKG_MANIFEST
- INVALID_PACKAGE_NAME
AI-assisted analysis of pnpm/pnpm@5b11d3a15b (2026-08-16).
Data as JSON: /api/errors/ab4fd49180a850a0.
Report an issue: GitHub.