Skip to content
Today's Tech Byte: Patching a dependency with pnpm

Today's Tech Byte: Patching a dependency with pnpm

Posted on:October 18, 2023

Due to a bug in one of our applications, I had to patch a dependency, I was about to download patch-package, but I discovered that pnpm has a built-in patching feature, so I decided to give it a try.

Patching a dependency with pnpm

pnpm patch <package-name>

This will create a temporary directory with the patched package source code. After you make the changes you want, you can run pnpm patch-commit to commit the changes to the package’s source code.

You will find the patch file in the patches directory in the root of your project.

Applying patches

To apply the patches, you need to run pnpm install or pnpm update to install the patched version of the package.