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.
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
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:
Next, write out the following command to a react app named ‘
Change to the newly created React application directory and execute these commands:
cd linuxtips-app npm start
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”.
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.