Setting Up Development Environment For React Native on Windows

Recently, I decided to explore and use React Native for developing Android Apps. However, as I was setting up my development environment on Windows, I ran into a lot of challenges. Setting up React Native on Windows is challenging and requires attention to a lot of moving pieces, even if you want to get a sample app up and running on an emulator.

In this article, I will discuss how to set up your development environment on Windows using React Native framework and Android Studio to build Android Apps.

I will be using the following tools to set up my development environment:

  • Visual Studio Code
  • Install Chocolatey
  • Node Package Manager (NPM)
  • Node.js (Version 12 or newer)
  • React Native command line interface (React Native CLI)
  • React Native command line interface (React Native Expo)
  • Java Development Kit (JDK 8 or newer)
Visual Studio Code Website Screenshot for Download
Visual Studio Code
  • Open Powershell
  • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.
  • Now run the following command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  • Run the following command to install nodejs and jdk8
choco install -y nodejs.install openjdk8

Note: Make sure you add NPM and JDK8 to the PATH environment variable.

If you have already installed Node on your system, make sure it is Node 10 or newer. If you already have a JDK on your system, make sure it is version 8 or newer.

  • Once npm is installed, install React Native CLI and Expo CLI by running the following command from the Windows prompt command line or Integrated Terminal in Visual Studio Code.

Note: Integrated Terminal can be found under View →Integrated Terminal

npm install -g react-native-clinpm install -g expo-cli

Finally, let’s create our first React Native CLI application by running the following command in your workspace location

react-native init SampleReactNativeProject

let’s create our first React Native CLI application by running the following command in your workspace location

expo init SampleReactNativeExpoProject

This creates the following project directory structure when you open the project in Visual Studio Code.

React Native Initial Directory Structure
React Native Initial Directory Structure
React Native Initial Directory Structure

Now run the following command to install the app and see it running on your phone.

  • Connect your phone to your laptop using USB Cable and Enable Developer options and USB DEBUGGING.
  • And run the following command:
react-native run-android

React Developer | React Native Developer | Machine Learning | AI Enthusiast | Self-Learner | ACES — Vice-President