npm audit Explained

What npm audit does, with an example.

Published November 10, 2026

npm audit scans your dependency tree against known vulnerability databases and reports severity and fix suggestions.

How it works

npm audit fix applies compatible updates; --force may take breaking upgrades. Results include transitive dependencies that you do not control directly.

Use --omit=dev to focus on production risk.

Try it

npm audit
12 vulnerabilities (3 high)
npm audit fix
fixed 9 of 12 vulnerabilities

Practical examples

Report

npm audit

Production only

npm audit --omit=dev

Automatic fixes

npm audit fix

CI gate

npm audit --audit-level=high

Common mistakes

  • Using --force blindly.
  • Ignoring high-severity runtime issues.
  • Treating every advisory as exploitable.

Key takeaways

  • npm audit scans your dependency tree against known vulnerability databases and reports severity and fix suggestions.
  • Run npm help <command> for every option.
  • Commit package-lock.json.

FAQ

Is a finding always a risk?

Only if the vulnerable code path is reachable in your use.

Does this work with yarn or pnpm?

They have equivalents with similar commands.

More JavaScript articles