How to Install ReactJS on Ubuntu

Developed by Facebook in 2011, React (also referred to as ReactJS) is a Javascript library used for creating fast and interactive user interfaces. At the time of writing, it’s the most popular Javascript library for developing user interfaces. React trounces its counterparts – Angular and Vue JS in terms of functionality and popularity.

Its popularity stems from its flexibility and simplicity and this makes it the first choice in the development of mobile apps and web applications. More than 90,000 sites use React including tech giants such as Facebook, Netflix, Instagram, Airbnb, and Twitter to list a few.

In this article, you will learn how to install ReactJS on Ubuntu 20.04 and Ubuntu 18.04.

Step 1: Installing NPM in Ubuntu

We begin the installation of React JS by installing npm – short for the node package manager, is two things. Firstly, it is a command-line tool that is used for interacting with Javascript packages, which allows users to install, update, and manage Javascript tools and libraries.

Secondly, npm is an online open-source software registry that hosts over 800,000 Node.JS packages. Npm is free and you can easily download software applications that are publicly available.

To install npm on Ubuntu Linux, login into your server as a sudo user and invoke the command below:

$ sudo apt install npm

Once the installation is complete, you can verify the version of npm installed using the command:

$ npm --version

6.14.4  [Output]

The latest version at the time of writing this is v6.14.4 as captured in the output.

The installation of npm also installs node.js and you can confirm the version of node installed using the command:

$ node --version

v10.16.0  [Output]

Step 2: Installing create-react-app Utility

create-react-app is a utility that enables you to set up all the tools required to create a React Application. It saves you a great deal of time and energy setting everything from scratch and gives you the head start needed.

To install the tool, run the following npm command:

$ sudo npm -g install create-react-app
Install Create React App Tool
Install Create React App Tool

Once installed, you can confirm the version of installed by running:

$ create-react-app --version

4.0.1  [Output]

Step 3: Create & Launch Your First React Application

Creating a React application is quite simple & straightforward. We are going to create a react app called tecmint-app as follows.

$ create-react-app tecmint-app

This takes roughly 5 minutes to install all the packages, libraries, and tools needed by the application. Some patience will come in handy.

Create React App
Create React App

If the creation of the application was successful, you will get the notification below giving the basic commands that you can run to start managing the application.

Summary of React App
Summary of React App

To run the application, navigate into the app directory

$ cd tecmint-app

Then run the command:

$ npm start

You will end up getting the output below showing you how to access the application on the browser.

Run React App
Run React App

Fire up your browser and browse your server’s IP address

http://server-ip:3000
Access React App on Browser
Access React App on Browser

This shows that the default React app is up and running. In this guide, we have successfully installed React JS and created an application in React.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Winnie Ondara
Winnie Ondara
Contributor
About the author

My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

3 Comments

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.