When switching between two branches that modifies a patch file, it will cause patch-package to always fail to apply the changes unless you delete node_modules.
Steps to reproduce
Checkout a branch in your repo e.g. patch-package-1.
Patch any library and commit the changes.
Checkout a new branch based on this one e.g. patch-package-2.
Patch the library again with new code and commit the changes.
Switch between the branches and try to install dependencies, you will always get an error and the patch won’t be applied, unless you delete node_modules.
**ERROR** Failed to apply patch for package expensify-common at path
node_modules/expensify-common
This error was caused because patch-package cannot apply the following patch file:
patches/expensify-common+1.0.0.patch
Try removing node_modules and trying again. If that doesn't work, maybe there was
an accidental change made to the patch file? Try recreating it by manually
editing the appropriate files and running:
patch-package expensify-common
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
https://github.com/ds300/patch-package/issues
---
patch-package finished with 1 error(s).
Case 2
Details
When switching from a branch that uses multi-patches feature in a library to a branch that does not in the same library, it will cause patch-package to always fail to apply the changes unless you delete node_modules.
Steps to reproduce
Checkout a branch in your repo e.g. patch-package-1.
Patch any library and commit the changes.
Checkout a new branch based on this one e.g. patch-package-2.
Patch the library again with new code using --append and commit the changes.
Switch from patch-package-2 to patch-package-1 and try to install dependencies, you will always get an error and the patch won’t be applied, unless you delete node_modules (same error as Case 1).
⚠️ Switching from patch-package-1 to patch-package-2 won't cause this error.
Case 1
Details
When switching between two branches that modifies a patch file, it will cause
patch-package
to always fail to apply the changes unless you deletenode_modules
.Steps to reproduce
patch-package-1
.patch-package-2
.node_modules
.Case 2
Details
When switching from a branch that uses multi-patches feature in a library to a branch that does not in the same library, it will cause
patch-package
to always fail to apply the changes unless you deletenode_modules
.Steps to reproduce
patch-package-1
.patch-package-2
.--append
and commit the changes.patch-package-2
topatch-package-1
and try to install dependencies, you will always get an error and the patch won’t be applied, unless you deletenode_modules
(same error as Case 1).patch-package-1
topatch-package-2
won't cause this error.