npx patch-package for sub-dependency

212 views Asked by At

I have two versions of a module installed, one that is a direct dependency, and the other of which is a sub-dependency:

./node_modules/@react-navigation/native/node_modules/react-native-gesture-handler
./node_modules/react-native-gesture-handler 

I have a code change to fix a compatibility problem with the first copy of react-native-gesture-handler above. But this is a sub-dependency of react-navigation.

If I try to do npx patch-package react-navigation it finds no changes. If I try to do npx patch-package react-native-gesture-handler it patches the second copy, which is not what I need.

Is there any way to use npx patch-package to patch a sub-dependency like above?

1

There are 1 answers

0
Shivo'ham On BEST ANSWER

npx patch-package@react-navigation/react-native-gesture-handler will not work because the patch package will check your package.json file inside /native folder and native is necessary because inside native you need to patch that node module.

npx patch-package@react-navigation/react-native-gesture-handler

to

npx patch-package@react-navigation/native/react-native-gesture-handler