Applying a Patch, Command, or Dependency Installation When Generating a Build with Expo in React Native

Tiempo de lectura: 2 minutos

Reading Time: < 1 minutes

I’m going to explain how you can run the installation of an npm package with flags or any other command when generating a build with React Native:

In this case, we need to apply this dependency installation:

npm i react-native-picker-select --save --legacy-peer-deps

Step 1: Create an .npmrc File

First, create a file named .npmrc at the root with the following content:


Step 2: Add the eas-build-pre-install Command in package.json

To automatically install react-native-picker-select when the build is generated, add the following command in the "eas-build-pre-install" script in your package.json file within the "scripts" section:

"scripts": {
     "eas-build-pre-install": "npm config set legacy-peer-deps true"

This command will run automatically before the build is generated, and it will install react-native-picker-select in your project with the --legacy-peer-deps flag.

Please note that this command will only execute if the build is generated successfully. If there is an error in the build, the command won’t run.

Step 3: Generate the Build

Once you have added the "postbuild" command to your package.json file, you can generate the build of your React Native project by running the following command in the terminal:

npm run build

This command will compile and package your React Native application for distribution.

You can also generate the build by uploading it to EAS (EXPO) with this command:

eas build -p android --profile production

Step 4: Verify the Installation of react-native-picker-select

Once the build is generated, verify that react-native-picker-select has been installed correctly in your project. You can do this by looking for the node_modules folder in your project and checking that the react-native-picker-select folder is present.

Leave a Comment