Skip to main content
Installation

Install Reactjs on Ubuntu

Learn to install ReactJS on Ubuntu and create a sample React application in this quick tutorial.

Sagar Sharma

Developed by Facebook, React is one of the most popular front-end JavaScript libraries that is used by tech giants like Netflix, Twitter, Facebook, and many more.

And in this tutorial, you will learn the following:

  • How to install ReactJS on Ubuntu
  • How to install and use create-react-app to create react an application

Let's see how to do it.

How to install ReactJS on Ubuntu

🗒️
There is no separate React package in Ubuntu. It is installed as a Node module. The best way to get react is to install the create-react-app node module.

To install react, you must install npm first, which is available from the universe repository.

So if you haven't added the universe repository, you can refer to our detailed guide on how to add the universe and multiverse repository on Ubuntu.

Once you have enabled the universe repository, use the following command to install react:

sudo apt install npm

To confirm the installation, you can check the installed version of npm using the following command:

npm --version
check the npm version on ubuntu

And to check the node version, you can use the following command:

node --version
check the node version on ubuntu

That's a pretty old version and it won't work with the create-react-app utility.

So let's update the Node to the latest version.

Update Node to the latest version

To update the node, all you need is a tool named n which can be installed with the npm:

npm install -g n 

And finally, install the latest LTS release of Node (18.14.2 while writing):

sudo n lts

Now, log out and log back in and check the node version:

install the latest LTS version of Node on ubuntu

How to install the create-react-app utility

If you don't know, the create-react-app utility avails you of every necessary tool that is used to create a react application.

Unlike the previous installation, you will have to use the npm package manager to install this package:

sudo npm -g install create-react-app

Once you are done with the installation, check the installed version:

create-react-app --version
check the installed version of create-react-app on ubuntu

How to create React application on Ubuntu

In this section, I will walk you through how you can create a sample react application from the installation you've made previously.

To create a react application, all you have to do is append the desired name of the application to the create-react-app command:

create-react-app [Name_your_application]

For example, here, I created a sample application named learnubuntu:

create-react-app learnubuntu

It will take a couple of minutes and if things go smoothly, you will get the following message after the successful installation of your application:

how to create react application in Ubuntu

To run this application, first, you will have to change your directory to the application:

cd [application_name]

And finally, start the application using the following command:

npm start
run react application on ubuntu

Now, you can use any of your preferred browsers to check the application by using the given link.

And it will show you something like this:

run react application on browser using ubuntu

There you have it!

Feel free to 'react' to this article in the comment section.

Sagar Sharma