How to Install ReactJS on Ubuntu 20.04

Install ReactJS on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure ReactJS on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

React. js is an open-source JavaScript library that is used for creating web frontend and UI components specifically for single-page applications. It’s used for handling the view layer for web and mobile apps. Many well-known corporations such as Facebook, Uber, and Instagram used the ReactJS framework to create interfaces.

Install ReactJS on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install Node.js.

Node.js is required to create and run a React.js application. Run the following command below to install Node.js:

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

Next, install Node.js using apt command:

sudo apt install nodejs

Check the currently active version of Node.js Also, you can check the npm version using the following command:

node -v
npm -v

Step 3. Install Reactjs on the Ubuntu system.

Now we set up all of the settings and tools required for creating a react application:

sudo npm -g install create-react-app

Verify its successful installation:

create-react-app --version

Next, write out the following command to a react app named ‘linuxtips-app’:

create-react-app linuxtips-app

Change to the newly created React application directory and execute these commands:

cd linuxtips-app
npm start

Output:

Compiled successfully!
You can now view myreactapp in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.1.7:3000
Note that the development build is not optimized.
To create a production build, use npm run build.

Step 4. Accessing ReactJS.

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

http://your-server-ip:3000

Install ReactJS on Ubuntu 20.04

That’s all you need to do to install ReactJS on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on Install ReactJS, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.