chore: pin npm via corepack to stop package-lock drift - #264
Merged
Conversation
`npm i` kept rewriting package-lock.json with no dependency change. Root cause is npm-version skew across contributors and CI: - CI pinned Node 22 → npm 10; local Node 24 → npm 11. npm 11 serializes the lockfile differently (peer flags, optional-peer handling), and `npm ci` never rewrites it, so the format ping-ponged. - Worse, the skew is patch-level: npm 11.6.2 prunes the optional-peer @emnapi/* entries while CI's npm 11.16.0 `npm ci` requires them — so a lockfile written by 11.6.2 fails CI outright. Fix: make everyone — contributors and both CI jobs — use one exact npm. - package.json `packageManager: npm@11.16.0`; corepack resolves that exact npm locally and in CI (`corepack enable` step in both workflows). - engines floor node >=22, npm >=11.16.0 + .npmrc engine-strict=true so a pre-11.16.0 npm fails fast instead of silently rewriting the lockfile. - .nvmrc → 24; both workflows switch node-version 22 → node-version-file. - Regenerate package-lock.json with npm 11.16.0 (canonical, complete tree).
marc0olo
force-pushed
the
chore/pin-node-npm-version
branch
from
August 4, 2026 13:33
12b2813 to
8ee812b
Compare
Skill Validation ReportNo skill files were changed in this PR — validation skipped. |
raymondk
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm ikept rewritingpackage-lock.jsonwith no dependency change. The cause is npm-version skew between contributors and CI — and it turned out to bite at the patch level:node-version: 22→ npm 10; local Node 24 → npm 11. npm 11 serializes the lockfile differently (peer flags, optional-peer handling), and sincenpm cinever rewrites the lockfile, the format ping-ponged between anyone who rannpm i.@emnapi/core/@emnapi/runtimeentries, while CI's npm 11.16.0npm cirequires them. A lockfile written by 11.6.2 therefore fails CI withnpm ci can only install ... when package.json and package-lock.json are in sync.So a version floor alone is not enough — the fix has to make everyone use one exact npm.
Fix
Pin the exact npm with corepack, for contributors and both CI jobs:
package.json→"packageManager": "npm@11.16.0"corepack enablestep in both workflowsengines:node >=22,npm >=11.16.0+.npmrcengine-strict=true.nvmrc→24; both workflowsnode-version: 22→node-version-file: .nvmrcnvm usestay alignedpackage-lock.jsonregenerated with npm 11.16.0The lockfile diff is a 12-line normalization: adds the
enginesblock and lets npm 11.16.0 tidypeerflags. No dependency version or integrity changes; 0 vulnerabilities.Contributor note (one-time)
corepack ships with Node. Enable the npm shim once:
corepack enable npmAfter that,
npmin this repo automatically resolves to the pinned11.16.0. If you're on an older npm without corepack enabled,engine-strictwill refuse to install until you do.Verification
corepack-resolved
npm ci+ build + stability