pnpm: Cannot install pnpm with corepack: `corepack use pnpm@latest-x`

Verify latest release

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

pnpm version

9.15.3, 9.15.5

Possibly all versions of pnpm installed via corepack.

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

CLI

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

Reproduction steps

This applies to both CI and local environment, fail at run: pnpm install

jobs:
  Build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version-file: ".nvmrc"

      - run: corepack enable pnpm

      # Fail here
      - run: pnpm install

Describe the Bug

Error message:

Run pnpm install
  pnpm install
  shell: /usr/bin/bash -e {0}
/opt/hostedtoolcache/node/[2](https://github.com/user/user-app/actions/runs/13104702477/job/36557589587?pr=379#step:6:2)0.18.2/x64/lib/node_modules/corepack/dist/lib/corepack.cjs:215[3](https://github.com/user/user-app/actions/runs/13104702477/job/36557589587?pr=379#step:6:3)5
  if (key == null || signature == null) throw new Error(`Cannot find matching keyid: ${JSON.stringify({ signatures, keys })}`);
                                              ^

Error: Cannot find matching keyid:

It works before the recent release. I’m assuming 9.15.5 broke something?

Expected Behavior

Expect to download and run pnpm install:

Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-9.15.3.tgz

Which Node.js version are you using?

v20.18.2

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)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 191
  • Comments: 36 (8 by maintainers)

Commits related to this issue

Most upvoted comments

You may have installed corepack with npm previously, in which case using pnpm to upgrade may fail. Use npm instead:

npm i -g corepack@latest

(I suppose you could run pnpm setup to set the global bin directory and mitigate the error but I didn’t explore this option.)

And yes, my corepack version was 0.29.3 and once I upgraded it to 0.31.0 the error went away.

[!WARNING] I highly recommend NOT disabling the integrity check by using COREPACK_INTEGRITY_KEYS=0 when there is a better way.

This is unfortunately an ongoing issue in corepack: https://github.com/nodejs/corepack/issues/612

It can be bypassed by either:

Updating the global version of corepack:

pnpm i -g corepack@latest

Or by having corepack not check integrity keys when preparing pnpm:

COREPACK_INTEGRITY_KEYS=0 corepack prepare

Just leaving a comment here, if anybody can use our fix. We had this issue in Azure Pipelines. We didn’t pin the PNPM version, so I guess it just used the latest version. By pinning the version in our Pipeline to what we use in DEV, currently pnpm@9.15.0, we resolved the issue.

This is our pipeline setup:

- script: corepack enable
  displayName: "Enable Corepack"

- script: corepack prepare pnpm@9.15.0 --activate
  displayName: "Corepack set PNPM version"

- script: pnpm config set store-dir $(pnpm_config_cache)
  displayName: "Setup pnpm store dir"

For some reason, we had to separate the script into multiple chunks to get the corepack prepare command working.

Error: Cannot find matching keyid: {"signatures":[{"sig":"MEQCIHGqHbvc2zImUPEPFpT4grh6rMYslel+lAjFArx8+RUdAiBfnJA+bgmUvO5Lctfkq+46KKDQdx/8RhLPge3pA+EdHA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"keys":[{"expires":null,"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg=="}]}

My workaround to deal with this bug:

  1. Update the packageManager version to pnpm@10.0.0.
  2. Add the script corepack prepare pnpm@10.0.0 --activate to the Dockerfile:
ARG NODE_VERSION=lts

FROM node:${NODE_VERSION}-slim AS base

# Configure pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# WORKAROUND HERE:
RUN corepack prepare pnpm@10.0.0 --activate

# Copy project files
COPY . /app
WORKDIR /app

# Install dependencies
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --ignore-scripts --frozen-lockfile

# Build the project
RUN pnpm build

...

I have tried other pnpm versions, but versions 10.1.0 and 9.15.5 didn’t work.

Update:

Following the info from @zkochan, the corepack version 0.31.0 can also fix this issue:

ARG NODE_VERSION=lts

FROM node:${NODE_VERSION}-slim AS base

# Configure pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

# COREPACK UPDATE HERE: 
RUN corepack enable && npm install -g corepack@latest

# this workaround is no longer necessary with corepack 0.31.0:
# RUN corepack prepare pnpm@10.0.0 --activate

# Copy project files
COPY . /app
WORKDIR /app

# Install dependencies
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --ignore-scripts --frozen-lockfile

# Build the project
RUN pnpm build

...

same error for node:22.11.0-slim image. I might be able to avoid it by running pnpm install after npm install --global corepack@latest.

If you are using Node.js 22.x LTS there is now a new release with the Corepack fix.

Node.js v22.14.0 includes the fixed version: Corepack 0.31.0.

As far I understand the corepack team has published a fix in their latest version. So, you can fix the issue by upgrading corepack to latest.

@ARiyou2000

FROM node:${NODE_VERSION}-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack // we needed this
RUN corepack enable
RUN corepack prepare pnpm@10.2.0 --activate // and this

WORKDIR /app
...

I was able to fix these errors by adding the two commented lines above. Now, pnpm 10.2.0 is working.

If you still encounter issues, you might want to try running npm install -g corepack@latest first. I hope one of these solutions works for you.

@AleksandrHovhannisyan

Add ENV COREPACK_DEFAULT_TO_LATEST=0 to your Dockerfile

FROM node:20

WORKDIR /app

COPY package.json package.json
COPY pnpm-lock.yaml pnpm-lock.yaml

RUN corepack enable
ENV COREPACK_DEFAULT_TO_LATEST=0
RUN corepack install
RUN pnpm install --frozen-lockfile

The node:20 Docker image currently ships with Corepack 0.29.4.

For <= pnpm@9.15.4, pnpm@10.0.0

Corepack Workaround
<= 0.26.0 none needed
0.27.0 - 0.30.0 COREPACK_DEFAULT_TO_LATEST=0
0.31.0 none needed

In docker environment corepack enable && corepack prepare pnpm@9.15.5 --activate works for me.

npm i -g corepack@latest fixed it for me too

As far I understand the corepack team has published a fix in their latest version. So, you can fix the issue by upgrading corepack to latest.

yep, updating corepack fixed it for me!

@MikeMcC399 thank you for your prompt response.

corepack -v
0.31.0

A re-installation of corepack has solved the issue.

corepack use pnpm@latest
Installing pnpm@10.4.1 in the project...

Lockfile is up to date, resolution step is skipped
Already up to date
Done in 553ms using pnpm v10.4.1

corepack up             
Installing pnpm@10.4.1 in the project...

Lockfile is up to date, resolution step is skipped
Already up to date
Done in 587ms using pnpm v10.4.1

Thanks again

The error Cannot find matching keyid: ${JSON.stringify({ signatures, keys })} in a Docker build, specifically within the context of PNPM and Corepack, indicates an issue with verifying the signatures of packages being installed. This usually arises due to a mismatch between the expected and actual keys used to sign the packages in the npm registry.

So I Updated my Node version from 20 to 22 and it worked!

- FROM node:20-alpine AS base
+ FROM node:22-alpine AS base
FROM node:${NODE_VERSION}-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack // we needed this
RUN corepack enable
RUN corepack prepare pnpm@10.2.0 --activate // and this

WORKDIR /app
...

I was able to fix these errors by adding the two commented lines above. Now, pnpm 10.2.0 is working.

If you still encounter issues, you might want to try running npm install -g corepack@latest first. I hope one of these solutions works for you.

This also works for me

@aisiklar

Came here from #9053 I upgraded my corepack version to 0.31.0 (with npm i -g corepack@latest) but corepack install -g pnpm@10.2.0 command or a previous version did NOT upgrade pnpm, though it did not give any error. Any idea what i might be missing? Thanks

corepack install -g affects the global default version

If you want to update pnpm used in a specific project, then try the following, executing in your project directory:

corepack use pnpm@10.2.0 Check the documentation https://github.com/nodejs/corepack/blob/main/README.md for more details on the commands.

if that doesn’t work, then you’ll need to provide a bit more detail about exactly what you are doing.

@MikeMcC399 hello, Thanks for the response. when i checked the doc before I remember seeing the “use” command but thought that I needed to first install the new version of the pnpm. That is why i used the command corepack install -g and thought there was an error because when i pnpm -v on a directory different from my project it showed the same version (not upgraded it)

Anyway, as a last word, this worked. now that, pnpm -v shows correctly the 10.2.0 version. in my project folder and other folders.

I think I need to read the docs more carefully.

Thanks again alptekin

I also fixed it by changing this:

corepack enable && corepack prepare pnpm@latest --activate && pnpm install && pnpm dev

…to this:

corepack enable && corepack prepare pnpm@9.15.4 --activate && pnpm install && pnpm dev

…but that’s only a temporary fix.

Most solutions offer to just upgrade corepack with npm i -g corepack, but we use Docker, so I believe we’re stuck? I mean, the Docker image ships with a certain version of Node which also comes with the corresponding Corepack version, as that’s an internal Node.js feature.

We can’t use version 9.15.4 forever. What would need to happen before we could revert to using @latest? What does that new version of pnpm have to publish?

FROM node:${NODE_VERSION}-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g corepack // we needed this
RUN corepack enable
RUN corepack prepare pnpm@10.2.0 --activate // and this

WORKDIR /app
...

I was able to fix these errors by adding the two commented lines above. Now, pnpm 10.2.0 is working.

If you still encounter issues, you might want to try running npm install -g corepack@latest first. I hope one of these solutions works for you.

This work for me

also had this issue, run this in a docker container base step to stop the builds failing we pinned to 9.15.4

FROM node:22-slim AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable && \ corepack prepare pnpm@9.15.4 --activate