Skip to content

[BUG] --ignore-patch-failures writes a lockfile that disagrees with package.json #9573

Description

@manzoorwanijk

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

This is not just a request to bump a dependency for a CVE

  • This is not solely a request to bump a dependency for a CVE

Current Behavior

When a patch fails and the install is run with --ignore-patch-failures, the package is installed unpatched and the lockfile records no patched entry for it — but package.json still declares the patchedDependencies entry. The two artifacts now disagree: a subsequent npm ci fails with the generic out-of-sync EUSAGE error (while a plain npm install re-attempts and fails with EPATCHFAILED).

Expected Behavior

Failing on a genuinely broken patch is reasonable. But the resulting state — a lockfile that is immediately npm ci-invalid against its own unchanged package.json — is surprising. A clearer message tying the out-of-sync state back to the skipped patch would help.

Steps To Reproduce

REPRO=/tmp/patch-ignore-fail && rm -rf "$REPRO" && mkdir -p "$REPRO" && cd "$REPRO"
cat > package.json <<'EOF'
{ "name": "ipf", "version": "1.0.0", "dependencies": { "is-positive": "3.1.0" } }
EOF
npm install --no-audit --no-fund

mkdir -p patches
cat > patches/[email protected] <<'EOF'
--- a/index.js
+++ b/index.js
@@ -1,3 +1,4 @@
 NONEXISTENT
+x
 fake
 lines
EOF
node -e "const fs=require('fs');const p=require('./package.json'); \
  p.patchedDependencies={'[email protected]':'patches/[email protected]'}; \
  fs.writeFileSync('package.json',JSON.stringify(p,null,2))"

npm install --no-audit --no-fund --ignore-patch-failures   # warns, installs unpatched
npm ci --no-audit --no-fund                                # => EUSAGE: not in sync

Observed

The --ignore-patch-failures install succeeds with a warning and writes a lockfile with no patched entry; npm ci then fails with EUSAGE (out of sync) against the unchanged package.json.

Expected

Either the artifacts stay consistent, or the npm ci failure message ties the out-of-sync state back to the skipped patch.

Environment

  • npm: 12.0.0-pre.0
  • Node.js: v24.15.0
  • OS Name: Darwin 25.5.0 (macOS, arm64)
  • Relevant config: none — reproduces with default configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions