Fixing security vulnerabilities in npm dependencies in less than 3 mins

A step-by-step guide to quickly resolve security issues in your Node.js projects

Apr. 11, 2026 at 1:29am

A highly detailed, 3D macro illustration of a complex circuit board and wiring, illuminated by vibrant neon blue and pink lights, conceptually representing the hidden vulnerabilities in software dependencies that developers must identify and fix.Glowing digital infrastructure symbolizes the hidden vulnerabilities that developers must proactively address to maintain the security of their Node.js applications.Cheboygan Today

A software engineer shares his experience and a detailed process for fixing security vulnerabilities in npm dependencies, including using the npm audit command, the resolutions key in package.json, and the npm-force-resolutions tool to quickly address issues without breaking existing functionality.

Why it matters

Unpatched security vulnerabilities in npm dependencies can expose applications to potential attacks, making it critical for developers to proactively identify and remediate these issues. This guide provides a practical, efficient approach to maintaining the security of Node.js projects.

The details

The author encountered security vulnerability alerts for the npm packages acorn and minimist in his project. He first tried running npm update, but that did not fully resolve the minimist vulnerability. The author then used the npm audit command to identify the affected dependencies, discovering that the minimist package was required by mkdirp, which was in turn required by the Mocha testing framework. To fix this, the author installed the non-vulnerable version of minimist, added a resolutions key to the package.json file, and used the npm-force-resolutions tool to ensure the dependency was properly updated across the project.

  • The author encountered the security vulnerability alerts in early 2020.

The players

Vivek Nayyar

The author of the article, a senior software engineer with experience building products for various domains.

npm

The popular JavaScript package manager used to manage dependencies in Node.js projects.

Mocha

A popular JavaScript testing framework that was affected by the minimist vulnerability.

Got photos? Submit your photos here. ›

What they’re saying

“If any of you in the recent time have seen something like this image below and have no clue how to fix it then this article is for you.”

— Vivek Nayyar, Author

“To check if the dependency works correctly”

— Vivek Nayyar, Author

What’s next

The author notes that while the resolutions approach can help fix the security vulnerability, developers should still carefully test their application to ensure the dependency change does not break any existing functionality.

The takeaway

This guide provides a practical, step-by-step process for quickly identifying and remediating security vulnerabilities in npm dependencies, an important skill for Node.js developers to maintain the security of their projects. The author's experience highlights the value of proactive dependency management and the use of tools like npm audit to stay on top of potential issues.