Skip to content

Commit eb2ddb2

Browse files
committed
ci: use corepack to pin npm 11.13.0, avoid self-upgrade race
`npm install -g npm@11.13.0` hits a known self-upgrade race on the GitHub-hosted ubuntu and macos runners: the in-flight npm 10 process tries to require modules that the new npm 11 has already overwritten, producing `Cannot find module 'promise-retry'` partway through reify-output. Corepack sidesteps this by managing npm via its own shim instead of overwriting Node's bundled npm. `corepack enable npm` is required because `corepack enable` alone only shims yarn/pnpm.
1 parent 2772399 commit eb2ddb2

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

.github/workflows/CI-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
node-version: 22
3636
cache: 'npm'
3737
registry-url: 'https://registry.npmjs.org'
38-
- run: npm install -g npm@11.13.0
38+
- run: corepack enable npm && corepack prepare npm@11.13.0 --activate
3939

4040
# build dist folder
4141
- run: npm ci

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ jobs:
4646
with:
4747
node-version: 22
4848
cache: 'npm'
49-
- run: npm install -g npm@11.13.0
49+
- run: corepack enable npm && corepack prepare npm@11.13.0 --activate
50+
shell: bash
5051

5152
- name: Smoke test Docker deps stage
5253
if: matrix.os == 'ubuntu-latest'

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
FROM node:22-slim AS builder
33

44
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates python3 make g++ && rm -rf /var/lib/apt/lists/*
5-
RUN npm install -g npm@11.13.0
5+
RUN corepack enable npm && corepack prepare npm@11.13.0 --activate
66

77
WORKDIR /app
88

@@ -23,7 +23,7 @@ RUN --mount=type=secret,id=github_token \
2323
FROM node:22-slim AS deps
2424

2525
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates python3 make g++ && rm -rf /var/lib/apt/lists/*
26-
RUN npm install -g npm@11.13.0
26+
RUN corepack enable npm && corepack prepare npm@11.13.0 --activate
2727

2828
WORKDIR /app
2929

0 commit comments

Comments
 (0)