Why?
As a Javascript developer, you might have come to a situation where you found a bug in a dependency you use.
As a good soul 😇, you have done a pull request with the fix. But what if the pull request is not yet accepted and you need this fix to deploy your project?! 🤔
Patch-Package 🚀
Patch-Package is a tool to patch
a dependency, it will create a .patch
file and it will patch the package after each npm install.
How?
- Open the file you want to edit and add your fix.
vim node_modules/package-name/file-to-edit.js
- Run :
npx patch-package package-name
This will create a .patch
file under a new repository patches/
Commit this file to your git repository
Finally add following script to your
package.json
. This will run after eachnpm install
and will patch the package.
"scripts": {
"postinstall": "patch-package"
}
Top comments (0)