If you want to develop mobile applications using React Native, you need to set up the development environment for the React Native CLI. In this blog post, I will show you the steps to do that on Windows.
Installing dependencies
You will need Node, the React Native command line interface, a JDK, and Android Studio.
While you can use any editor of your choice to develop your app, you will need to install Android Studio in order to set up the necessary tooling to build your React Native app for Android.
We recommend installing Node via Chocolatey, a popular package manager for Windows. It is recommended to use an LTS version of Node.
React Native also requires Java SE Development Kit (JDK), which can be installed using Chocolatey as well.
Open an Administrator Command Prompt (right click Command Prompt and select “Run as Administrator”), then run the following command:
choco install -y nodejs-lts microsoft-openjdk11
If you have already installed Node on your system, make sure it is Node 16 or newer. If you already have a JDK on your system, we recommend JDK11. You may encounter problems using higher JDK versions.
Note: If you don’t have Chocolatey installed, follow this Installation guide on windows.
Android development environment
Android Studio is an integrated development environment (IDE) that provides tools and emulators for developing Android applications. You can download and install Android Studio from https://developer.android.com/studio. During the installation, make sure you select the following components:
– Android SDK
– Android SDK Platform
– Android Virtual Device
You also need to set up some environment variables for the Android SDK. You can follow the instructions here: https://reactnative.dev/docs/environment-setup#android-development-environment
Create and run a React Native project
Now you are ready to create and run your first React Native project. You can use the React Native CLI to generate a project template:
react-native init MyProject
This will create a folder called MyProject with the necessary files and folders for a React Native project. To run the project on an Android emulator or device, you can use the following command:
react-native run-android
You should see your app running on the emulator or device. Congratulations, you have successfully set up the development environment for React Native CLI!