Setting up Environment for React Native CLI on Ubuntu

By StartxLabs
Date 10-06-19
Setting up Environment for React Native CLI on Ubuntu
" Setting up Environment for React Native CLI on Ubuntu"

On Ubuntu you can only test application for Android environment developed in react native, for iOS application Mac OS is mandate.

Begin with checking, updating and upgrading the packages available in your current ubuntu version.

To Update:

  • Open Terminal
  • Execute command ‘sudo apt-get update’

To Upgrade:

  • Open Terminal
  • Execute command ‘sudo apt-get upgrade’

Now your system is prepared to install all the dependency items for smooth running of react native application.

1. Install Node and NPM

  • Open Terminal
  • Execute command ‘sudo apt install nodejs’ and install the necessary packages.
  • Execute command ‘sudo apt install npm’ and install the necessary packages.

 

2. Install REACT NATIVE CLI

  • Open Terminal
  • Execute command ‘sudo npm install -g react-native-cli’ and install the necessary packages.

 

3. Setup Environment for JAVA

  • Open Terminal
  • Execute command ‘sudo apt-get install openjdk-8-jdk’ and install the necessary packages.

 

4. Setup environmental variables for JAVA

  • Open .bash_profile by executing the command ‘sudo gedit $HOME/.bash_profile’
  • Paste the below mentioned lines in it
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/

     

  • Update path variables by saving and exiting from the file and executing the command ‘source $HOME/.bash_profile’

 

5. Setup Environment for Android

  • Download Android Studio from the official site (https://developer.android.com/studio/)
  • Extract the package downloaded
  • Move the extracted package to the directory you want.
  • Open the terminal and ‘cd’ to the bin directory inside android-studio directory.
  • Execute the studio.sh file by typing ‘./studio.sh’ and press enter.
  • Android installation setup will begin, go through all the steps pressing next and downloading all the necessary files.

 

6. Setup environmental variables for Android SDK

  • Open .bash_profile by executing the command ‘sudo gedit $HOME/.bash_profile’
  • Paste the below mentioned lines in it
    export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/tools/bin export PATH=$PATH:$ANDROID_HOME/platform-tools

     

  • Update path variables by saving and exiting from the file and executing the command ‘source $HOME/.bash_profile’

 

7. Install ADB

  • Open Terminal
  • Execute command ‘sudo apt install adb’ and install the necessary packages.

 

8. Install Watchman

During the installation of watchman you may encounter issues related to several missing packages. Before installing Watchman go through below steps

  • Install libtoolize by executing command ‘sudo apt-get install libtool’
  • Install automake tool by executing command ‘sudo apt-get install automake’
  • Install pkg-config by executing command ‘sudo apt install pkg-config’
  • Install python dev tools by executing command ‘sudo apt-get install python-dev’
  • Install watchman following the steps mentioned here (https://facebook.github.io/watchman/docs/install.html#buildinstall) or you just can follow below mentioned steps:
  • Clone the watchman from GitHub using command ‘git clone https://github.com/facebook/watchman.git'
  • Execute command ‘cd watchman’
  • Checkout to head ‘git checkout v4.9.0’ (Check for latest release here https://facebook.github.io/watchman/docs/install.html#buildinstall)
  • Execute script autogen.sh by executing command ‘./autogen.sh’
  • Execute script configure.sh by executing command ‘./configure’
  • Execute command ‘make’
  • Execute command ‘sudo make install’

 

You are all set now. You can begin working on your React Native project simply by executing command ‘react-native init <Project Name>’

subscribe to startxlabs

startxlabs