Search code examples
javascriptnode.jsdependenciesnpm

How to patch a dependency of a npm library?


I experienced a bug in a deep dependency of a library installed using the npm. I fixed that bug in a fork and created a pull request on github.

I'm wondering how to share my fix with my co-workers. I found this article but since it's not my dependency but a dependency of a library I use I don't know how to solve this problem.

Even if my pull-request get's accepted fast, I need to wait for the maintainer of the library to update his dependencies, what may never even happen.

Is there any common way how to solve such a thing?


Solution

  • by using patch-package, you can patch the dependency of a dependency like:

    npx patch-package package/another-package

    or in scoped package

    npx patch-package @my/package/@my/other-package

    please check the package docs