The instructions are here: patch-package - npm
I’m using yarn
, so assuming I was trying to work around this issue in the expo-image-picker
package, I would do something like the following:
The dependencies from package.json
:
"dependencies": {
"expo": "~43.0.2",
"expo-image-picker": "~11.0.3",
"expo-status-bar": "~1.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-web": "0.17.1"
},
In node_modules/expo-image-picker
there’s a file called app.plugin.js
. This is the config plugin’s entry point. You’ll see it only contains the following line:
module.exports = require('./plugin/build/withImagePicker');
So we need to look in node_modules/expo-image-picker/plugin/build/withImagePicker.js
. Open that file and remove the lines mentioning android.permission.CAMERA
and android.permission.RECORD_AUDIO
.
Then run patch-package
as follows:
myapp$ npx patch-package expo-image-picker
patch-package 6.4.7
• Creating temporary folder
• Installing expo-image-picker@11.0.3 with yarn
• Diffing your files with clean files
✔ Created file patches/expo-image-picker+11.0.3.patch
💡 expo-image-picker is on GitHub! To draft an issue based on your patch run
yarn patch-package expo-image-picker --create-issue
Then add the patch to Git:
myapp$ git add patches
myapp$ git commit -m "Don't add CAMERA and RECORD_AUDIO Android permissions"
[master 5f6eff5] Don't add CAMERA and RECORD_AUDIO Android permissions
1 file changed, 15 insertions(+)
create mode 100644 patches/expo-image-picker+11.0.3.patch
Then in order for it to work during the build you’ll need to follow the patch-package
“Set-up” instructions:
Scripts section from package.json
:
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"postinstall": "patch-package"
},
Install patch-package
as a dev dependency and commit the changes:
myapp$ yarn add --dev patch-package postinstall-postinstall
[...]
$ patch-package
patch-package 6.4.7
Applying patches...
expo-image-picker@11.0.3 ✔
Done in 4.77s.
myapp$ git commit -am "Install patch-package"
[master a14d8dd] Install patch-package
2 files changed, 106 insertions(+), 4 deletions(-)
Then try building a package and I think that should solve the problem for now. When the Expo team updates the expo-image-picker
package to make the Android permissions configurable, upgrade that package, uninstall patch-package
, remove the patches
directory and the patch file and remove the post-install
script from package.json
.