FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(ci): don't error on optional deps in the lockfile by wraithgar · Pull Request #9083 · npm/cli · GitHub

/ cli Public

fix(ci): don't error on optional deps in the lockfile - #9083

Merged
wraithgar merged 1 commit into
latestfrom
gar/optional-ci
Mar 9, 2026
Merged

fix(ci): don't error on optional deps in the lockfile#9083
wraithgar merged 1 commit into
latestfrom
gar/optional-ci

Conversation

Copy link
Copy Markdown
Contributor

We build a virtual tree from the lockfile before we build the ideal tree so that we can compare the two and error if package.json differs from what was used to build the lockfile.

The virtual tree includes optional deps in it that would otherwise be ignored when building the ideal tree. In order not to have npm ci fail in this situation we need to build the virtual tree separately, and start clean when building the ideal tree.

This also brings in a few linting fixups.

We build a virtual tree from the lockfile before we build the ideal tree so that we can compare the two and error if package.json differs from what was used to build the lockfile.

The virtual tree includes optional deps in it that would otherwise be ignored when building the ideal tree.  In order not to have `npm ci` fail in this situation we need to build the virtual tree separately, and start clean when building the ideal tree.

This also brings in a few linting fixups.
wraithgar requested a review from a team as a code owner March 9, 2026 16:43

Copy link
Copy Markdown
Contributor Author
~/D/s/doc-kit $ node /Users/gar/Development/npm/cli/branches/gar_optional-ci ci

added 634 packages, and audited 642 packages in 9s

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
~/D/s/doc-kit $ npm ci
npm error code EBADPLATFORM
npm error notsup Unsupported platform for @unrs/resolver-binding-android-arm-eabi@1.9.2: wanted {"os":"android","cpu":"arm"} (current: {"os":"darwin","cpu":"arm64"})
npm error notsup Valid os:   android
npm error notsup Actual os:  darwin
npm error notsup Valid cpu:  arm
npm error notsup Actual cpu: arm64
npm error A complete log of this run can be found in: /Users/gar/.npm/_logs/2026-03-09T16_44_04_539Z-debug-0.log

wraithgar merged commit 76c76e5 into latest Mar 9, 2026
20 checks passed
wraithgar deleted the gar/optional-ci branch March 9, 2026 17:09
github-actions Bot mentioned this pull request Mar 9, 2026
R4FF7dev pushed a commit to R4FF7dev/ketenmanagement that referenced this pull request Jul 11, 2026
Nixpacks' npm ci step was failing with "Missing: X@... from lock
file" for unstorage's optional peer dependency on lru-cache (never
actually installed, since this app uses none of unstorage's optional
cloud-storage drivers). This is a known npm bug (npm/cli#9083, fixed
in npm 11.11.1): npm ci built its lockfile-validation "virtual tree"
and install "ideal tree" with a shared Arborist instance, incorrectly
flagging legitimately-absent optional deps as missing. Nixpacks'
nodejs_22 nix package almost certainly bundles an older, unfixed npm.

package.json/package-lock.json are confirmed in sync (fresh reinstall
produces zero diff), so this isn't a real lockfile problem — routing
Nixpacks' install phase through npm install instead sidesteps the
buggy npm ci codepath entirely, regardless of npm patch version.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
guarzo added a commit to guarzo/authGD that referenced this pull request Aug 24, 2026
)

`npm ci` failed on a clean checkout with EUSAGE, naming a version that
appears nowhere in package-lock.json:

    npm error Missing: esbuild@0.28.2 from lock file
    ... (+26 @esbuild/* platform packages, all 0.28.2)

while `npm install --package-lock-only --dry-run` reported "up to date".

The lockfile is not at fault and is unchanged here. `vitest`'s nested
`vite@8.2.2` declares esbuild as an *optional* peerDependency
(`^0.27.0 || ^0.28.0`, `peerDependenciesMeta.esbuild.optional = true`),
and nothing in the lock satisfies that edge at that location — which is
correct, because an unsatisfied optional peer should be skipped. Older
npm instead resolves it against the registry (arborist's `loadPeerSet`),
picks up whatever is current, then rejects the lock as out of sync. That
is also the install-vs-ci contradiction: the two commands build the tree
by different paths and disagree about optional peers.

Fixed upstream by npm/cli#8981 (npm 11.10.1) and npm/cli#9083
(npm 11.11.1). Node 24.15.0 is the first 24.x bundling npm >= 11.11.1.

CI was never affected: `.nvmrc` is bare `24`, so setup-node floats to
v24.19.0 / npm 11.17.0. The failure only reached environments sitting on
an old-but-in-range Node 24, which `engines.node: ">=24"` permitted.
Regenerating the lockfile under npm 11.17.0 reproduces it byte for byte;
regenerating under an affected npm instead commits esbuild 0.28.2 and 26
platform packages that CI does not install.

`.nvmrc` deliberately stays bare `24` — the repo pins by major, and
scripts/check-node-version.sh compares majors only, so it still passes.

Also corrects two references the new floor invalidated: the Dockerfile
comment that quoted "node >=24" (now states the floor without repeating
a value that can drift) and the docs/ops.md local-dev requirement.
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL