-->

Setting up your Linux machine for React Native Development

By: Ananthu A Nair 9 months, 3 weeks ago

ENVIRONMENT SETUP

You will need Node, the React Native command line interface, Python2, 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.


Setting up for Linux
Dependencies (Install instructions below)

i. Node
sudo apt-get install -y nodejs

ii. React Native CLI
npm i -g react-native-cli

iii. Java Developer Kit
    1. You will need your Linux version: Get it by typing hostnamectl in your terminal
    2. Download the correct JDK file from here
    3. Extract the JDK package and you are good to go. (Usually just double click on the downloaded file and the files should be extracted to root for you).

iv. Android Studio
    1. Download Android Studio here
    2. Extract the download to a folder of your choice (or just root directory).
    3. cd {your-extracted-directory}/android-studio/bin
    4. ./studio.sh
    5. Check "Do not import settings" when prompted. (Unless you have a previous version of Android Studio and you'd like to import its configs).
    6. Follow the Wizard
    7. Check all boxes for:
        Android SDK, Intel x86 Atom_64 System Image or Google APIs Intel x86 Atom System Image, Android SDK Platform API 28 or greater , Android Virtual Device
    8. Finish and download!
    9. When it's finished downloading, you can close Android Studio

    Configure JAVA_HOME & ANDROID_HOME environment variables

Check if you have a .bash_profile file in your root directory with command ls -a in your terminal and check for the.bash_profile file
If you don't have a .bash_profile in your root directory create it with command touch .bash_profile

Open your bash profile by command nano .bash_profile and add:

export JAVA_HOME="$HOME/jdk1.8.0_181" // Or your version of the jdk
export PATH=$PATH: "$JAVA_HOME/bin"
export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools export PATH=$PATH:$ANDROID_HOME/emulator


Then ctrl + o to write out, hit Enter and then ctrl + x to close the editor


v. Watchman

First install Linuxbrew:
sudo apt install linuxbrew-wrapper
Then:
brew update && brew install watchman (might get a warning, just hit Enter)
Last:
Configure .bashrc for correct path to npm.
npm list -g | head -n 1 will give you the path to npm

Now let's add the path to npm into the .bashrc file:

export PATH="$HOME/.npm-global/bin:$PATH"

Now you're ready to create your first React Native App!

You may folow this article to create your first react native app.

Comments

Let us talk!

We take the vision which comes from dreams and apply the magic of science and mathematics, adding the heritage of our profession and our knowledge to create a design.