How to remove a nested dependency in pnpm

Viewed 43

For example in my project I include svgo which has a deprecated dependency stable which results into warning during installation:

 WARN  deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility

I can remove this package from source code of svgo via pnpm patch, but how to also exclude it from package resolution to avoid PNPM WARN?

If I manually remove stable package from lock file, it will appear again after using pnpm update.

1 Answers

svgo will fail without stable

If you remove stable, svgo won't run, because it uses stable.

Fork instead

Instead, you should fork the package make the necessary code changes to svgo, then use your modified. Thanksfully, people on the internets have already done this for you.

All you need to do is

npm i boidolr/svgo#remove-stable

This should replace svgo with the edited version that has no stable.

Related