zach.codes

Share this post

User's avatar
zach.codes
Patching npm modules with patch-package
Copy link
Facebook
Email
Notes
More

Patching npm modules with patch-package

When nobody wants to merge a PR in time....

Zach Silveira's avatar
Zach Silveira
Oct 04, 2023
∙ Paid

Share this post

User's avatar
zach.codes
Patching npm modules with patch-package
Copy link
Facebook
Email
Notes
More
2
Share

A couple weeks ago, I updated a package. expo-router to be specific.

For some reason nobody wanted to merge a simple fix for a console warning that keeps appearing incorrectly.

When this happens you have a few options

Use a different module

This isn’t ideal unless you are using a very simple npm package, but it’s something you can do if alternatives exist.

Patch the current package

Doing this in 2023 is incredibly easy, some package managers even have built in support. To keep this short and simple, I’ll just explain how to use the patch-package npm module.

If you are using yarn 1:

yarn add patch-package postinstall-postinstall

npm:

// add this to package.json

"scripts": {
  "postinstall": "patch-package"
}

// then
npm i patch-package

Yarn 2:

Use yarn-patch natively: https://yarnpkg.com/cli/patch

Patching Expo Router

For this problem, someone found the exact location of the problem and made a PR, it just didn’t get merged when I needed it fixed. They left a comment here.

To receive new posts and s…

Keep reading with a 7-day free trial

Subscribe to zach.codes to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zach Silveira
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More