Nexus Void Research

npm audit, npm, Node.js, Dependency Vulnerabilities, SCA, overrides, Supply Chain Security, How-to

How to Fix npm audit Vulnerabilities (Without Breaking Your Build)

How to fix npm audit vulnerabilities: npm audit fix, parent upgrades, overrides, when to use --force and how to undo it, and what to fix first.

To fix npm audit vulnerabilities, run npm audit fix to apply safe, semver-compatible upgrades, then handle what is left by hand: update the parent package that pulls in the vulnerable one, pin a patched version with overrides in package.json, or replace the package. Use npm audit fix --force only on a branch, because it can install breaking major versions. Fix what is exploited and reachable first.

npm audit compares the exact versions in your package-lock.json against a public advisory database and lists every known vulnerability in your dependency tree. On a typical Node.js project that list is long, and most of it sits in transitive dependencies you never installed directly. This guide shows how to clear it without breaking your build, and how to decide what actually needs fixing. All commands work with npm 8.3 or later.

What does npm audit actually check?

npm audit reads your lockfile, sends the package names and versions to the npm registry's audit endpoint, and reports any advisories that match, with a severity (low, moderate, high, critical) and the dependency path that brings each package in. It does not check whether your code calls the vulnerable function, whether the package only runs in development, or whether the flaw is being exploited. That is why its counts are high and why severity alone is a poor guide, as we show in vulnerability statistics for 2026.

Useful variations:

npm audit                       # full report
npm audit --omit=dev            # production dependencies only
npm audit --audit-level=high    # exit non-zero only for high and critical (useful in CI)
npm audit --json > audit.json   # machine-readable output
npm audit                       # full report
npm audit --omit=dev            # production dependencies only
npm audit --audit-level=high    # exit non-zero only for high and critical (useful in CI)
npm audit --json > audit.json   # machine-readable output
npm audit                       # full report
npm audit --omit=dev            # production dependencies only
npm audit --audit-level=high    # exit non-zero only for high and critical (useful in CI)
npm audit --json > audit.json   # machine-readable output

Step 1: Run npm audit fix

Start with the safe automatic fix. It upgrades vulnerable packages to a patched version only when that version still satisfies the semver ranges in your package.json, so it should not introduce breaking changes.

npm audit fix --dry-run   # preview what would change
npm audit fix             # apply it
npm audit fix --dry-run   # preview what would change
npm audit fix             # apply it
npm audit fix --dry-run   # preview what would change
npm audit fix             # apply it

Run your tests and commit package-lock.json. On many projects this clears a large share of the report. Whatever remains needs one of the steps below.

Step 2: Find out why each remaining package is installed

For every package still listed, find which of your direct dependencies pulls it in:

npm explain minimist
npm ls minimist
npm explain minimist
npm ls minimist
npm explain minimist
npm ls minimist

The output shows the dependency path, for example your-app > build-tool@4.2.0 > old-helper@1.0.3 > minimist@0.0.8. That path tells you where the fix has to happen. If the vulnerable package is a direct dependency, upgrade it. If it is transitive, you usually fix it by upgrading the parent.

Step 3: Upgrade the parent package

Check whether a newer version of the direct dependency ships a patched version of the vulnerable package:

npm outdated
npm view build-tool versions --json
npm install build-tool@latest
npm outdated
npm view build-tool versions --json
npm install build-tool@latest
npm outdated
npm view build-tool versions --json
npm install build-tool@latest

A major-version bump of the parent may need code changes, so read its changelog. This is the cleanest fix because you stay on versions the maintainers tested together.

Step 4: Pin a patched version with overrides

When the parent has no release with the fix, force the patched version of the nested package with overrides in package.json (npm 8.3+):

{
  "overrides": {
    "minimist": "^1.2.8"
  }
}
{
  "overrides": {
    "minimist": "^1.2.8"
  }
}
{
  "overrides": {
    "minimist": "^1.2.8"
  }
}

You can scope an override to one parent only:

{
  "overrides": {
    "old-helper": {
      "minimist": "^1.2.8"
    }
  }
}
{
  "overrides": {
    "old-helper": {
      "minimist": "^1.2.8"
    }
  }
}
{
  "overrides": {
    "old-helper": {
      "minimist": "^1.2.8"
    }
  }
}

Then run npm install, run your tests and confirm with npm ls minimist that every copy resolved to the patched version. Overrides can break a parent that relies on old behaviour, so test the code paths that use it. Yarn uses resolutions and pnpm uses pnpm.overrides for the same job.

Step 5: Use npm audit fix --force carefully

npm audit fix --force installs whatever version clears the advisory, including breaking major versions, and in some cases it downgrades a package to an old major that happens to be unaffected. Run it only on a separate branch and review the diff of package.json and the lockfile line by line.

To undo it, restore the two files from git and reinstall:

git restore package.json package-lock.json
npm ci
git restore package.json package-lock.json
npm ci
git restore package.json package-lock.json
npm ci

Step 6: Decide what can wait

Not every finding deserves the same urgency. Sort what is left using four questions:

Question

If yes

If no

Is the CVE in the CISA KEV catalog or does it have a high EPSS score?

Fix now

Schedule it

Does production code import the vulnerable package?

Fix now

Lower priority

Is it a devDependency that only runs at build time?

Lower priority, unless it runs in CI with secrets


Is the service internet-facing?

Raise priority


A vulnerable package that only runs in your test runner is a much smaller risk than one parsing user input on a public API. Record the reason when you decide to accept a finding, so the next person does not re-triage it. Our guide to prioritizing vulnerabilities with CVSS, EPSS and KEV goes deeper.

Step 7: Replace abandoned packages

If a package has no patched release and no maintainer activity, overrides only delay the problem. Look for a maintained fork or an alternative, or remove the dependency if you only use a small part of it. A smaller dependency tree means fewer audits.

Step 8: Keep it clean in CI

Make new vulnerabilities fail the build instead of piling up:

npm ci
npm audit --omit=dev --audit-level=high
npm ci
npm audit --omit=dev --audit-level=high
npm ci
npm audit --omit=dev --audit-level=high

Pair this with a check for malicious and typosquatted packages, which npm audit does not catch until an advisory exists. See how to detect malicious npm packages. The OWASP Top 10 lists vulnerable and outdated components as a top web application risk for exactly this reason.

Common npm audit errors and fixes

Problem

Fix

"found 0 vulnerabilities" but you expected some

You may have no lockfile. Run npm install to create package-lock.json, then audit again

npm audit fix changes nothing

The patched version is outside your semver range. Upgrade the parent (step 3) or use overrides (step 4)

"fix available via npm audit fix --force"

It needs a breaking upgrade. Try step 3 first

ERESOLVE errors after an override

The override conflicts with a peer dependency. Scope it to one parent, or upgrade the parent instead

Audit endpoint errors behind a proxy or private registry

Point npm at a registry that supports the audit API, or audit in CI with public registry access

How does ARGUS fix npm vulnerabilities?

ARGUS does the triage in steps 2 and 6 for you and writes the fix in steps 3 and 4.

  1. It reads your lockfile (package-lock.json, yarn.lock or pnpm-lock.yaml) and matches every installed version against OSV advisories.

  2. It checks reachability. For JavaScript and TypeScript, ARGUS looks for imports of each vulnerable package in your source and marks the finding reachable, unreachable or unknown, with an evidence string. Unreachable findings drop down the list but never disappear.

  3. It ranks by exploitability. Each finding gets a 0 to 100 priority score that blends CVSS, EPSS, CISA KEV and reachability, so a reachable, actively exploited CVE comes first.

  4. It flags malicious and lookalike packages. Every dependency is checked against OSV's malicious-package feed, and names one edit away from popular npm packages are flagged as possible typosquats.

  5. It opens the fix. Click Assign to Agent and ARGUS generates the smallest upgrade, verifies it with a build and a re-scan, and opens a pull request for you to review and merge. It never merges on its own.

Limits: reachability is import-level, not call-graph. ARGUS needs a lockfile; a package.json without one yields no dependency findings. Read more about ARGUS SCA with reachability and automatic dependency fixes, or scan a repository free.

Frequently asked questions

How do I fix npm audit vulnerabilities?

Run npm audit fix first to apply safe, semver-compatible upgrades. For what remains, use npm explain <package> to find the parent, upgrade that parent, or pin a patched version with overrides in package.json. Use npm audit fix --force only on a branch, and test before merging.

Is npm audit fix --force safe?

Not by default. It installs whatever version clears the advisory, including breaking major upgrades and sometimes downgrades to an old major. Run it on a separate branch, review the package.json and lockfile diff, and run your tests. Undo it with git restore package.json package-lock.json and npm ci.

How do I fix npm audit vulnerabilities manually?

Find the dependency path with npm explain <package>, then either upgrade the direct dependency that brings it in, or add an overrides entry in package.json that pins the nested package to a patched version. Run npm install, confirm with npm ls <package>, and run your tests.

How do I undo npm audit fix --force?

Restore package.json and package-lock.json from git with git restore package.json package-lock.json, then run npm ci to reinstall the exact previous versions. If you already committed the change, revert that commit instead and run npm ci again.

Why does npm audit fix not fix all vulnerabilities?

npm audit fix only applies upgrades that stay within the semver ranges in your package.json. If the patched version needs a major upgrade of the package or of its parent, it is left for you to handle with a parent upgrade, an override or --force.

Should I fix vulnerabilities in devDependencies?

Usually with lower priority. DevDependencies run at build or test time, not in production, so most cannot be reached by users. The exception is build tooling that runs in CI with access to secrets or publishing tokens. Use npm audit --omit=dev to see production risk on its own.

What is the difference between npm audit and npm outdated?

npm audit lists installed versions with known security vulnerabilities. npm outdated lists packages that have newer versions available, whether or not the old version is vulnerable. Use audit to find security fixes and outdated to plan routine upgrades.

How do I use overrides to fix a vulnerable transitive dependency?

Add an overrides object to package.json naming the package and a patched version range, for example "minimist": "^1.2.8", or nest it under one parent to scope it. Run npm install and confirm with npm ls. Overrides need npm 8.3 or later; Yarn uses resolutions.

Does npm audit detect malicious packages?

Only once an advisory is published for them. A newly published malicious or typosquatted package can be installed before any advisory exists. Check new dependencies against a malicious-package feed, watch for names one character away from popular packages, and review install scripts.

DATA SOURCES

CISA KEV: https://www.cisa.gov/known-exploited-vulnerabilities-catalog ; FIRST EPSS: https://www.first.org/epss/ ; OWASP Top 10: https://owasp.org/Top10/

Liked this post? Share it: