How to NPM Package Patching with ‘patch-package’ in React Native
August 22, 2022
How to NPM Package Patching with ‘patch-package’ in React Native
Patch-package is the simplest way I have found so far to well.. patch a package.
Yes, it does exactly what it says on the tin.
How to install
Installation is dead simple. Add…
"scripts": {
...other scripts
"postinstall": "patch-package"
}
…to your package.json
file and install patch-package using yarn:
yarn add patch-package postinstall-postinstall
You might notice we’re actually installing two packages, namely patch-package and postinstall. The two work together, as will become clear in a bit.
How to use
To use patch-package, make your changes right in the package code in node_modules and run patch-package
. That’s it! It’ll create a patches
folder containing the diffs needed to update the package version you installed with the changes you made.
E.g you can check the example from this link https://github.com/prscX/react-native-photo-editor/issues/214