npm audit fix runs, but the vulnerabilities are still listed
found 12 vulnerabilities (3 low, 6 moderate, 3 high)Short answer
npm audit fix only installs versions that stay inside your declared version ranges. If the patched release needs a range change or a major upgrade, or only a dependency of a dependency is affected, npm leaves it in the report. Read the fix line per finding, then upgrade the parent package or use an override.
Fix it fast
1Find out which cause you have
List the findings with the path that pulls each one in. The 'fix available' line tells you which kind of fix you have.
npm audit2Match what you see, then jump to its fix
- 1
fix available via `npm audit fix --force` and a note about a semver major changeThe patched version is outside your declared rangeFix - 2
The vulnerable package is nested several levels down, and the parent is flagged tooOnly a dependency of a dependency is affectedFix - 3
Everything flagged sits under devDependencies such as test runners or lintersThe findings are in build tools that never shipFix
- 1
What does the error look like?
found 12 vulnerabilities (3 low, 6 moderate, 3 high)To address issues that do not require attention, run: npm audit fixTo address all issues (including breaking changes), run: npm audit fix --force
Cause 1 of 3
The patched version is outside your declared range
1Check
npm audit fix only updates to versions that need no range change. A fix that needs a new range or a major version is held back.
npm audit --json | grep -m5 -i isSemVerMajor2Fix
Update the direct dependency yourself, read its changelog for breaking changes, and run your tests. Use --force only after that, because it installs versions outside your ranges, including major ones.
npm install some-library@latest
npm test3Verify
The finding is gone from the report.
npm auditConfirmed by docs.npmjs.com
Cause 2 of 3
Only a dependency of a dependency is affected
1Check
A package can be flagged just because it depends on a vulnerable version of another one. Trace the path.
npm ls vulnerable-package2Fix
Update the parent that pulls it in. If the parent has no release yet and you have checked the newer version is compatible, pin it with an override in the root package.json.
{
"overrides": {
"vulnerable-package": "^2.1.4"
}
}3Verify
Reinstall, then audit again.
npm install
npm auditConfirmed by docs.npmjs.com
Cause 3 of 3
The findings are in build tools that never ship
1Check
Production installs can skip dev dependencies, and the audit can be limited the same way.
npm audit --omit=dev2Fix
Judge the production report first, and keep dev tool findings on a normal upgrade schedule. For CI, set the level that should fail the build.
npm audit --omit=dev --audit-level=high3Verify
The command exits 0 when no finding at or above that level remains.
npm audit --omit=dev --audit-level=high
echo $?Confirmed by docs.npmjs.com
How do I stop it coming back?
- Update dependencies in small steps, often, so a major jump is never forced on you in one go.
- Commit the lockfile and review audit output in CI with --audit-level.
- Never run npm audit fix --force on a branch you cannot test or revert.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npm install refuses with ERESOLVE and a peer dependency conflict
npm error ERESOLVE unable to resolve dependency tree
ERESOLVE means two packages in your tree ask for incompatible versions of a shared peer dependency, and npm 7 or newer refuses to guess.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix