Skip to content

Commit cc12e58

Browse files
committed
fix(ci): avoid npm self-overwrite during publish workflow upgrade
1 parent 674ccf5 commit cc12e58

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ jobs:
4747
registry-url: 'https://registry.npmjs.org'
4848
cache: pnpm
4949

50-
# npm >= 11.5.1 is required for trusted publishing (OIDC)
50+
# npm >= 11.5.1 is required for trusted publishing (OIDC).
51+
# Install into a separate prefix first to avoid the self-overwrite
52+
# MODULE_NOT_FOUND bug seen when npm rewrites its own files in place.
5153
- name: Upgrade npm
52-
run: npm install -g npm@latest
54+
run: |
55+
npm install --prefix "$RUNNER_TEMP/npm-upgrade" npm@latest
56+
echo "$RUNNER_TEMP/npm-upgrade/node_modules/.bin" >> "$GITHUB_PATH"
5357
5458
- name: Install dependencies
5559
run: pnpm install --frozen-lockfile

0 commit comments

Comments
 (0)