
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
patch-package
Advanced tools
The patch-package npm package allows users to keep track of modifications to node_modules. It is useful when a user needs to make a quick fix to a node module and wants to persist this change across installs without waiting for the upstream fix. It lets you keep your workarounds in version control.
Creating Patches
This command is used to create a patch file for the npm package 'some-package'. After making changes to the node module, running this command will generate a patch file in a directory that can be committed to version control.
npx patch-package some-package
Applying Patches
This command applies all patches from the patches directory. It is typically used in the postinstall script in package.json to ensure that patches are applied after every npm install.
npx patch-package
Applying Specific Patch
This command applies a patch to a specific package. It is useful when you want to apply a patch to 'some-package' without applying all available patches.
npx patch-package some-package
Shrinkwrap is a tool for locking down the versions of npm packages installed. It is similar to patch-package in that it helps maintain consistency in dependencies, but it does not allow for modifications to the package code itself.
patch-package lets you easily fix bugs in (or add functionality to) packages in your
node_modules
folder and share the results with your team. You simply make the changes in situ,
run patch-package <package-name>
and patch-package will create a patch file
for you to commit, which gets applied any time the contents of node_modules
is updated by yarn/npm.
yarn add -D patch-package
In package.json
"scripts": {
"prepare": "patch-package"
}
Make changes to the files of a particular module in your node_modules folder, e.g. react-native. Then run:
patch-package react-native
If this is the first
time you've used patch-package
, it will create a folder called patches
in
the root dir of your app. Inside will be a file called react-native:0.44.0.patch
which is a diff between normal old react-native and your special version. Commit this and you and your team will enjoy the same changes from here on out.
Do exactly the same thing to update the patch file, or just delete it if you don't need the changes anymore.
MIT
1.0.0
Initial broken release
FAQs
Fix broken node modules with no fuss
The npm package patch-package receives a total of 2,642,038 weekly downloads. As such, patch-package popularity was classified as popular.
We found that patch-package demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.