nodejs / nodejs/corepack

Error when upgrading pnpm to latest in `devEngines.packageManager`

Open
#874 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
279
Avg merge
1h 47m
Merged PRs (30d)
2

Description

If pnpm is previously set at a specific version such as 11.12.0 in devEngines.packageManager:

package.json

{
  "devEngines": {
    "packageManager": {
      "name": "pnpm",
      "version": "11.12.0+sha512.820a6fbd0d9f04c226638002aead1e45340a9139dd5dc077c1d83ef44aa2481c8eb6637b4c9aa696a3c7e35ba818e49cf27213e5f2b91138d09b7a3e26e898ba"
    }
  }
}

Then upgrading using corepack use pnpm@11.13.0 (or corepack use pnpm@latest) fails with a confusing error:

$ corepack use pnpm@11.13.0
Installing pnpm@11.13.0 in the project...
Usage Error: The requested version of pnpm@11.13.0+sha512.88d94724d8f2e6c186744a5584c6e59ecac869ec7ba15e9cb4cd628e8dc7066820b2481d8ee3b51ea8da323a7378068aa58c556a3720d32b7c20a051d088363a does not match the devEngines specification (pnpm@11.12.0+sha512.820a6fbd0d9f04c226638002aead1e45340a9139dd5dc077c1d83ef44aa2481c8eb6637b4c9aa696a3c7e35ba818e49cf27213e5f2b91138d09b7a3e26e898ba)

$ corepack use <pattern>

It appears to be caused by Corepack attempting to add a packageManager field for 11.13.0 which conflicts with devEngines.packageManager's version of 11.12.0.

Some projects only want to rely on devEngines.packageManager, instead of also using packageManager or duplicating the fields.

Could Corepack instead update the version in devEngines.packageManager and not attempt to add packageManager?

Related issues

It appeared at first that this was related to issue #729, but I think my issue here is narrower - about a specific failure case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported failure with a package.json containing devEngines.packageManager, then run corepack use pnpm@11.13.0 or corepack use pnpm@latest. Trace the command's handling of devEngines.packageManager and packageManager; done means the requested version updates without a conflicting packageManager specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.