6

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.

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265
kunji mamu
  • 81
  • 1
  • 9
  • If i good understand the patch script is runing in 'postinstall' so changes made to package.json will not apply to code because then you will have to run upgrade or install after modification again. (easy to go in loop). – Robert May 29 '21 at 08:37
  • You can write your own script witch will fire after installation. You will have to go to dir and run npm install package name@version – Robert May 29 '21 at 08:43

2 Answers2

9
npx patch-package some-package --exclude 'nothing'

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

lukeliasi
  • 239
  • 2
  • 5
1

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.

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265