How to Install and Setup React Native on Ubuntu
React is a well-known JavaScript framework for developing front-end applications. It became popular through the use of intuitive programming paradigms that tie JavaScript to an HTML-like system known as JSX. This allows developers to create their applications in a shorter time.
Initially, setting up a new React project used to involve complex multi-stage processes such as setting a build system, converting the code transpiler to a code readable by all browsers and the basic directory structure. Now, the creation of React Apps has become simple with the Create React App CLI tool that includes all JavaScript packages, code transpilers, and the testing and building systems, that you need to run a React project.
React Native is a framework that creates a JavaScript code hierarchy of UI components. It has a set of components to build a mobile app with an authentic look and feel for both iOS and Android platforms. ReactJS, by contrast, is a JavaScript open-source library for user interfaces. While they may have different interfaces, Facebook developed React Native and ReactJS using the same design principles.
We will learn how to install and setup React Native on Ubuntu in this article. For successful installation, all of the steps below must be followed one after the other.
To download and successfully install React-Native to your pc, you need to consider the minimum hardware specifications required to support the app and run it smoothly.
To efficiently install and set up React-Native on your Ubuntu device, you will need to install the following:
Follow these steps to install Node.js which is a popular JavaScript implementation.
1. First update the apt package manager:
2. Now, run the following command:
Following Node.js installation, proceed with NPM or Node Package Manager installation.
3. These commands will help you know if it has been already installed or not:
4. If NPM is already installed, it will return:
5. To NPM, run the command in terminal:
Java is used to build native Android apps. This means that Java Development Kit (JDK) is required for working with projects in React Native.
Install the JDK with the following commands:
To work with React Native development, Android studio must be installed. From the website listed below we can easily download it.
For More details on the installation process of Android SDK please click here.
The most recent Android SDK comes by default with Android Studio. But it’s the Android 6.0 (Marshmallow) SDK that is required to build a React Native app with native code. You can install additional Android SDKs in Android Studio via the SDK Manager.
You can access the SDK Manager from the Android Studio Welcome screen. Click on Configure and choose SDK Manager.
SDK manager -> SDK platforms
Then check the box in the bottom right corner of the “Show Package Details” box. Find and expand the Android 6.0(Marshmallow) entry, and then make sure you check the following items:
1. Run the command:
In order to build apps with native code, the React Native tools need some environmental variables.
2. Copy the lines below and paste them into the terminal:
Save and exit the file using below commands:
Press Ctrl + O (Write out)
Then press Enter
And press Ctrl + x (exit)
You first need to install Autotools-dev which is a package with several other tools, i.e. aclocal automaker, before going ahead and installing Watchman. Copy and paste in the terminal to install it:
In order to continue the installation, you will be asked to choose a Y/N option. Please enter Y, then press Enter.
Once the Autotools-dev is installed, proceed and install Watchman, a Facebook tool for file system surveying. If you want the best results, you must install the tool.
Run these commands to install Watchman:
Flow allows you to easily add JavaScript to the static type check. It also helps to prevent bugs and makes documentation of code easier. In fact, it is already used by many React Native Documents and source code and must be installed.
Use the following command to install flow:
1. The next step is to instal React Native. It should be noted that you need to use sudo to have React Native installed as root, since we will be installing it globally. This is the code you must use:
2. Users who installed NPM with another method can install React Native as a normal user using this code:
You can go ahead and start creating your own app(s) when you’re done by installing all the necessary packages!
Only apps downloaded by the Google Play can be set up and run by default on most Android devices. To install your app during development, you need to enable USB Debugging on your device.
You will first need to activate the Developers options menu by going to Settings — About phone —Software Information — and then tap the Build number row at the bottom seven times to activate your device’s USB debugging system.
You can then return to Developer Settings to enable “USB debugging.”
Let’s start on an Android device now to run our React Native projects. Go forward to your development machine and plug in your device using USB.
Check the manufacturer code with lsusb:
Output will be like:
Several devices were connected to the USB device. Our Android device is:
These 4 digits, which form part of the device ID, will be required from this line of code:
Next, the following code in the terminal needs to be copied and pasted:
Start the DemoApp project by executing the below code:
The code on a terminal is as follows:
A failed code shows that other services in the system use the default React Native port. The following code can then be tested:
Removal of npm modules / third-party libraries is nearly identical to npm modules installation. The following command allows you to uninstall the third-party libraries in React Native. Substitute the package name with <name>.
This command removes the package from both node modules folder and package.json. You can use the following command if you want to delete the dependency in the global scale:
Use the uninstall command with -g flag to uninstall global package in the command line.
For example:
Learn the core concepts of React Native Components, API, and Navigation with React Native Training
Although the REACT Native Framework has some loopholes, it is still the number one choice for developers in the React Native development industry. We have successfully installed React Native on Ubuntu 18.04 server and created our first React App.
Check the manufacturer code with lsusb:
Several devices were connected to the USB device. Our Android device is:
These 4 digits, which form part of the device ID, will be required from this line of code:
Next, the following code in the terminal needs to be copied and pasted:
Start the DemoApp project by executing the below code:
A failed code shows that other services in the system use the default React Native port. The following code can then be tested:
Research & References of How to Install and Setup React Native on Ubuntu|A&C Accounting And Tax Services
Source