Ubuntu setup React Native

Ubuntu setup React Native

In this post, I am setting up React Native in Ubuntu 18.04. Before we begin, we need to check if we have all the prerequisites. Once all prerequisites are installed, we will proceed with setting up a React Native project. Finally running the app in Expo app in iOS and Android.

Java Development Kit (JDK)

Check your JDK version to see if you currently have JDK installed. In my screenshot, I do not have JDK installed.

# Check if you have JDK installed
javac -version

# Run the below command to install JDK
sudo apt install openjdk-8-jdk-headless
ubuntu setup react native
JDK not found in my Ubuntu 18.04.


Check your python version to see if you had python installed.

# Check your python version
python -v

# Run the below command to install python
sudo apt install python
ubuntu setup react native
Python not found in my Ubuntu 18.04.

Node.js and npm

Check your Node.js and npm version to see if you had it installed.

# Check Node.js version
node -v

# Check npm version
npm -v

# Install Node.js
sudo apt install nodejs

# Install npm
sudo apt install npm
ubuntu setup react native
Node.js and npm not found in my Ubuntu 18.04.

Create React Native project

# This is for generating React Native project files
sudo npm install -g create-react-native-app

# Create a new project MyReactNativeApp
sudo create-react-native-app MyReactNativeApp
ubuntu setup react native
Successfully created MyReactNativeApp project.

Setting Permissions

Earlier we created the React Native project with sudo because it needs to write some files into /usr/local/ directory. Now we need to change the project files owner back to myself.

# Changeing the owner from root to myself
cd ~
sudo chown -R kevinfoo:kevinfoo .expo/
sudo chown -R kevinfoo:kevinfoo MyReactNativeApp/

Running the app

cd MyReactNativeApp
expo start
ubuntu setup react native
Successfully starting the app.
ubuntu setup react native
Install the Expo client in iOS or Android and scan the QR code to run it.

Expo client

Expo client is available for download at their official site.