Ubuntu

How to Install ReactJS on Ubuntu 20.04

Install ReactJS Ubuntu 20.04

Introduction:

React is a very powerful front-end library of JavaScript that can be used to define user interfaces and related components. It is an open-source library that is maintained by Facebook. Today’s article will teach you the method of installing ReactJS on your Ubuntu 20.04 system.

Method of Installing ReactJS on your Ubuntu 20.04 System:

For installing ReactJS and running the respective applications on your Ubuntu 20.04 system, you need to perform the steps that follow:

Step # 1: Add the Relevant PPA Repository to your Ubuntu 20.04 System:

You need to add the NodeJS PPA repository to your Ubuntu 20.04 system since a ReactJS application can only run on your system if NodeJS is installed on your system. The said repository can be added with the following command:

$ curl –sL https://deb.nodesource.com/setup_14.x | sudo bash -

The successful addition of the said repository to your Ubuntu 20.04 system will render the messages shown in the image below on the terminal:

Step # 2: Install NodeJS on your Ubuntu 20.04 System:

After that, you can install NodeJS on your Ubuntu 20.04 system with the following command:

$ sudo apt install nodejs –y

Once NodeJS has been installed on your Ubuntu 20.04 system, you will receive the success messages shown in the image below:

Step # 3: Check the Installed Version of NodeJS on your Ubuntu 20.04 System:

You can verify the successful installation of NodeJS on your Ubuntu 20.04 system by checking its version with the following command:

$ node –v

The version of NodeJS installed on our Ubuntu 20.04 system is 10.19.0 as shown in the image below:

Step # 4: Install Yarn on your Ubuntu 20.04 System:

Now you need to install Yarn on your Ubuntu 20.04 system, with the following command:

$ sudo npm install –g yarn

With the successful installation of Yarn on your Ubuntu 20.04 system, you will get the messages shown in the image below on the terminal:

Step # 5: Create your First ReactJS Application on Ubuntu 20.04:

You can now create your first ReactJS application on Ubuntu 20.04 with the following command:

$ sudo npm init react-app myfirstreactapp

Alternatively, you can also create a ReactJS application with the command that follows:

$ yarn create react-app myfirstreactapp

It will take a few minutes for the successful creation of a ReactJS application as shown in the image below:

Step # 6: Navigate to your ReactJS Project Directory:

After creating your ReactJS application successfully, you need to move to its project directory with the following command:

$ cd myfirstreactapp

Step # 7: Start your ReactJS Application in Ubuntu 20.04:

Now you need to start your ReactJS application with the command shown below:

$ npm start

It will take some time for the development server to start as shown in the following image:

You will be able to view your ReactJS application in your default web browser by giving your localhost address followed by port number “:3000” as shown in the image below:

Conclusion:

In this guide, we taught you the correct method of using ReactJS on a Ubuntu 20.04 system by installing NodeJS and required dependencies on it. Finally, we demonstrated to you the usage of ReactJS by creating a sample application.

Similar Posts