How to install ReactJS on Ubuntu 20.04

Web development encompasses many different tools and in this post, you will learn how to install one of them because installing ReactJS can open the doors to creating fantastic things for the web. Also, the post will be done on Ubuntu 20.04 which is a system widely used by many developers in the world.

Introducing to ReactJS

ReactJS is an open-source JavaScript library focused on visualization. This technology allows us to develop user interfaces simply, this is possible through interactive and reusable components. Needless to say, it is widely used around the world, and more and more are being added every day.

One of the reasons is that React provides several clear advantages over the classic way of making a web, its ease of development coupled with performance, flexibility, and code organization makes it one of the best options. For example, React avoids a lot of spaghetti code by using several libraries such as JQuery.

Therefore, React represents a solid base on which you can build almost anything with Javascript. It also makes development much easier, as it offers us many ready-made things, in which we don’t need to invest time and effort.

So, it is possible to install it on Ubuntu 20.04 with a few steps and get started.

Install ReactJS on Ubuntu 20.04

First, connect to your server or open a terminal session from the main menu.

Make sure the system is fully up to date.

sudo apt update
sudo apt upgrade

Install NodeJS on Ubuntu 20.04

The installation of ReactJS will be done via NodeJS which is in the official Ubuntu repositories, but the version available is quite outdated. So we will install the latest stable through the NodeJS repository.

So we need to install the curl and gnupg2 packages to can add the NodeJS repository.

sudo apt-get install curl gnupg2

Now download and run the script that allows us to add the NodeJS repository.

curl -sL | sudo bash -

If everything went well, you will get an output screen like this:

## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL | gpg – dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

Next, install NodeJS with the following command:

sudo apt install nodejs

Along with NodeJS, you install npm which is a package manager for NodeJS. It is a good idea to have it updated so that there are no problems with the installation.

sudo npm install [email protected] -g


/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ [email protected]
added 58 packages from 23 contributors, removed 241 packages and updated 194 packages in 5.207s

Now, you can check the version of NodeJS that has been installed.

node -v

Install ReactJS on Ubuntu

With NodeJS installed, we can then install ReactJS by running the following command:

sudo npm install -g create-react-app

At the end of the process, you will see an output screen similar to this:

added 67 packages, and audited 68 packages in 3s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

And at last, you will be able to create the application in React.

create-react-app [project_name]
Success! Created example at /home/user/example
 Inside that directory, you can run several commands:
 npm start
     Starts the development server.
 npm run build
     Bundles the app into static files for production.
 npm test
     Starts the test runner.
 npm run eject
     Removes this tool and copies build dependencies, configuration files
     and scripts into the app directory. If you do this, you can’t go back!
 We suggest that you begin by typing:
 cd example
   npm start
 Happy hacking!

Assign the name you want to your project and it will start creating it. As a result, a new folder with the name of your project will be created.

cd [project_name]

And you can start the local server by running

npm start

Sample Output

Compiled successfully!

You can now view example in the browser.


Note that the development build is not optimized.
To create a production build, use npm run build.

To exit press CTRL + C and if you are using React on a virtual machine then you have to make it accessible from any host.

npm start – – port=3000

Whatever the case, open a web browser and you can verify that ReactJS is ready by going to the address http://host:3000 remember this can be the IP address of your computer, or if you installed it on your computer then it is http://localhost:3000.

ReactJS on Ubuntu 20.04
ReactJS on Ubuntu 20.04

This indicates that React has been installed properly.


ReactJS is a technology that helps a lot in creating graphical interfaces for the web. Being more and more used it has become one of the most preferred technologies by developers in the world. And as you may have noticed, it is very easy to install it on a computer running Ubuntu 20.04.

So, share this post and help us grow.

Share This: