How To Install React Native - A Step By Step Guide

React Native uses Node.js, a JavaScript runtime, to build your JavaScript code. React Native also requires a recent version of the Java SE Development Kit (JDK) to run on Android. Follow the instructions for your system to make sure you installed the required versions.

MacOS

First, install Homebrew using the instructions on the Homebrew website. Then, install Node.js by executing the following in the terminal.

brew install node 

Next, use homebrew to install watchman, a file watcher from Facebook.

brew install watchman 

This is used by React Native to figure out when your code changes, and rebuild accordingly. It’s like having Android Studio do a build each time you save your file.

Finally, download and install JDK 8 or newer if needed.

Windows

First, install Chocolatey using the instructions on the Chocolatey website.

Install Node.js if you don’t have it or have a version older than 4. Run the following command as Administrator (Right-click on Command Prompt and select “Run as Administrator”),

choco install -y nodejs.install 

Python is needed to run the React Native build scripts. Run the following command as Administrator if you don’t have Python 2.

choco install -y python2 

Run the following command as Administrator if you don’t have a JDK or have a version older than 8.

choco install -y jdk8 

Linux

Install Node.js by following the installation instructions for your Linux distribution. You will want to install Node.js version 6 or newer.

Finally, download and install JDK 8 or newer if needed.

React Native CLI

Use Node Package Manager (or npm) to install the React Native Command Line Interface (CLI) tool. In your terminal (Terminal or Command Prompt or Shell), type the following command -

npm install -g react-native-cli 

The npm fetches the CLI tool and installs it globally; npm is similar to JCenter in functionality and is packaged with Node.js.

Next, install Yarn using the instructions on the Yarn website. Yarn is another fast npm client.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now