Skip to content

Installing node as runtime dependency breaks store prune/status #10131

@oBusk

Description

@oBusk

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

Store

Link to the code that reproduces this issue or a replay of the bug

https://github.com/oBusk/pnpm-store-prune-error

Reproduction steps

  1. Add node to pnpm store

    • Either by installing a package that has node as a runtime dependency pnpm install
    • Or by adding node directly to the store pnpm store add node@runtime:22
  2. Run pnpm store status

  3. Run pnpm store prune

Describe the Bug

pnpm store prune will fail with an error trying to access undefined

$ pnpm store prune
Removed all cached metadata files
Removed 8908 files
 ERROR  Cannot read properties of undefined (reading 'integrity')

pnpm: Cannot read properties of undefined (reading 'integrity')
    at C:\snapshot\dist\pnpm.cjs
    at async Promise.all (index 953)
    at async prune (C:\snapshot\dist\pnpm.cjs)
    at async storePrune (C:\snapshot\dist\pnpm.cjs)
    at async C:\snapshot\dist\pnpm.cjs
    at async main (C:\snapshot\dist\pnpm.cjs)
    at async runPnpm (C:\snapshot\dist\pnpm.cjs)
    at async C:\snapshot\dist\pnpm.cjs

In some cases pnpm store status also fails,

ENOENT  ENOENT: no such file or directory, open '/home/runner/setup-pnpm/node_modules/.bin/store/v10/node@runtime+22.21.0/integrity.json'

From my researching of the pnpm code, it seems that the code for dealing with the store expects all packages in the store to be npm packages with package.json, but with the added support of installing node, node is also stored in the store, and does not have any package.json.

Expected Behavior

pnpm store status and pnpm store prune to work, with ability to prune unused version of node in the store.

Which Node.js version are you using?

22.21.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

WSL Ubuntu 20.04

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions