And in this tutorial, you will learn the following:
- How to install ReactJS on Ubuntu
- How to install and use
create-react-appto create react an application
Let's see how to do it.
How to install ReactJS on Ubuntu
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:
And to check the node version, you can use the following command:
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:
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:
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
For example, here, I created a sample application named
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:
To run this application, first, you will have to change your directory to the application:
And finally, start the application using the following command:
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:
There you have it!
Feel free to 'react' to this article in the comment section.