DEV Community

Smart Home Dan
Smart Home Dan

Posted on

1 1

NodeJS Basics: Fixing Dependency Security Issues

When hitting an issue with nodejs modules having security vunerabilties, I follow the below process. Assume the problematic module is sharp version 0.22.1

Updating the module

Check out the repository

npm ci

// That just makes sure we have every installed locally, same as the pipeline where this is failing

npm ls sharp

// We should now see how and where this problematic module is being used.

npm i sharp@0.28.2

// Now we install the fixed version at the top of our package.json tree. This will also update the references lower down the tree to our version. This should also update our package-lock.json file too.

npm ls sharp

// Lets verify that we have managed to update the module references correctly.

npm uninstall sharp

// If we dont use this module directly in our code (only in module dependancies, we can now remove it, but the version should be updated in our tree.

Make sure we now commit this package.lock to the repository, and our CI pipeline should have been sorted.

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay