Create and apply patches for file changes in node_modules.
A small (4.1kb minified + gzipped), fast alternative to patch-package. See the table of differences below.
Keep in mind that patch-files:
- Requires Node 18 or greater
- Should be run from the root of your project
To create a patch for a single file:
npx patch-files@latest node_modules/a/a.jsTo create a patch for multiple files:
npx patch-files@latest node_modules/a/a.js,node_modules/b/b.jsTo apply patches:
npx patch-files@latestTwo directories are created:
patch-filesis where patch files are writtenpatch-files-cacheis where the files fetched for comparison are written
You can apply patches in a postinstall script so patches are applied whenever you install your node modules:
{
"scripts": {
"postinstall": "npx patch-files@latest"
}
}patch-files |
patch-package |
|---|---|
| 4.1kb minified + gzipped as of v6.0.0 | 124.8kb minified + gzipped as of v6.5.0 |
| 0 dependencies | 14 dependencies |
| Downloads individual file(s) for comparison | Downloads entire npm modules for comparison |
| Does not depend on Git | Depends on Git |
| Relies on CDNs jsdelivr or unpkg | Relies on the npm registry |
| Requires Node 18 or greater | Requires Node 10 or greater |