React Native CLI Installation Guide for Linux (Ubuntu22.04)

React Native CLI Installation Guide for Linux (Ubuntu22.04)

Nodejs Installation

Install the Nodejs (Latest Version Preferrable) for Ubuntu distribution

$ sudo apt update
$ sudo apt install nodejs
$ sudo apt install npm
$ node --version    # Check For Successful Installation
$ npm --version
  • You can use NVM to install and maintain multiple nodejs version
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
$ source ~/.bashrc
$ nvm list-remote
$ nvm install v20.4.0
$ nodejs --version         # Check for Successful Installation
$ npm --version

OpenJDK Installation

  • Install the OpenJDK if not installed on your machine
$ sudo apt update
$ sudo apt install default-jre
$ sudo apt install default-jdk
$ javac --version         # Check for Successful Installation

Android Studio Installation

  • You Can Install Android Studio From The Snap Store
$ sudo snap install android-studio --classic

Install Watchman

  • Install Watchman from this Link and make sure to download the .deb file for ubuntu22.04

  • Watchman Github Release

  • Run this Command to install the package

$ sudo dpkg -i watchman_ubuntu20.04_v2023.09.18.00.deb
$ sudo apt -f install

Configure the Environment Varaible in the bash file

  • Open the bashrc file in your terminal
$ vi ~/.bashrc
  • Add these lines at the end of your bash file
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
  • Write ':wq' to quit and save the file and then source the bash file
$ source ~/.bashrc

Build Your React Native Project

  • Create a new folder for React-native projects
$ mkdir AllReactProjects
$ cd AllReactProjects/
$ npx react-native@latest init YourProjectName

** If you're facing gradle file/sudo privilege problems for the running directory then run,

chmod 755 AllReactProjects/

Run your First Program!

  • Cd into your project directory
$ cd YourProjectName/
  • Run the command for starting the react native application
$ npm start

And you're ready to start your journey of React Native!

Good Luck on your Journey!