React: Patching package.json using patch-package

6.7k views Asked by At

I am using the patch-package to patch a package.json file of one of my dependencies. I modified the package.json and ran npx patch-package [dependency_name] but it not capturing the changes made to the package.json. However, changes made to other files like index.js are captured. How do I patch the package.json? I am trying to modify the module and jsnext:main attributes.

2

There are 2 answers

3
lukeliasi On
npx patch-package some-package --exclude 'nothing'

https://github.com/ds300/patch-package/issues/49#issuecomment-646581987

0
Archimedes Trajano On

I was trying to use this for the same purpose, alas the answer is no from what I can tell.

The patch process comes after postinstall which means that the package.json is already processed with the invalid dependencies.

Aside from just creating a PR, I revendored the library and made my modifications as I cannot wait for a merge.