{"record":{"id":"ab4fd49180a850a0","repo":"pnpm/pnpm","slug":"missing-package-index-file","errorCode":"MISSING_PACKAGE_INDEX_FILE","errorMessage":"Failed to find package index file for ${pkg.id} (at ${err.path}), please consider running 'pnpm install'","messagePattern":"Failed to find package index file for (.+?) \\(at (.+?)\\), please consider running 'pnpm install'","errorType":"exception","errorClass":"PnpmError","httpStatus":null,"severity":"error","filePath":"pnpm11/deps/compliance/license-scanner/src/getPkgInfo.ts","lineNumber":83,"sourceCode":"      packageResolution,\n      pkg.id,\n      {\n        storeDir: opts.storeDir,\n        storeIndex: opts.storeIndex,\n        lockfileDir: opts.dir,\n        virtualStoreDirMaxLength: opts.virtualStoreDirMaxLength,\n      }\n    )\n    if (!result) {\n      throw new PnpmError(\n        'UNSUPPORTED_PACKAGE_TYPE',\n        `Unsupported package resolution type for ${pkg.id}`\n      )\n    }\n    files = result\n  } catch (err: any) { // eslint-disable-line\n    if (err.code === 'ENOENT') {\n      throw new PnpmError(\n        'MISSING_PACKAGE_INDEX_FILE',\n        `Failed to find package index file for ${pkg.id} (at ${err.path}), please consider running 'pnpm install'`\n      )\n    }\n    throw err\n  }\n\n  const manifestPath = files.get('package.json')\n  if (!manifestPath) {\n    throw new PnpmError(\n      'MISSING_PACKAGE_INDEX_FILE',\n      `Failed to find package.json in index for ${pkg.id}, please consider running 'pnpm install'`\n    )\n  }\n  const manifest = await readPackageJson(manifestPath)\n\n  // Determine the path to the package as known by the user\n  const modulesDir = opts.modulesDir ?? 'node_modules'","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/pnpm/pnpm/blob/5b11d3a15b9022a2109cb18ed96a5d652630371f/pnpm11/deps/compliance/license-scanner/src/getPkgInfo.ts#L65-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"CI pipelines that skip full installs for speed; `pnpm store prune` run between install and licenses scan; node_modules deleted but lockfile kept.","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"],"exampleFix":"// before\n$ pnpm install --lockfile-only && pnpm licenses list\n\n// after\n$ pnpm install && pnpm licenses list","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await getPkgInfo(pkg, opts)\n} catch (err) {\n  if (err instanceof PnpmError && err.code === 'MISSING_PACKAGE_INDEX_FILE' && /index file/.test(err.message)) {\n    await runInstall() // then retry once\n    return getPkgInfo(pkg, opts)\n  }\n  throw err\n}","preventionTips":["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"],"tags":["licenses","store","filesystem","install"],"backgroundTag":null,"analyzedSha":"5b11d3a15b9022a2109cb18ed96a5d652630371f","analyzedAt":"2026-08-16T13:18:59.198Z","schemaVersion":2},"datasetVersion":"2026-08-16T18:17:16.020Z"}