In this article, we’ll explain how to install React on Ubuntu 20.04.
React is an open-source, front end, JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.
This article will guide you with the installation process and deploying React site.
Prerequisites
- A Ubuntu 20.04 installed dedicated server or KVM VPS.
- A root user or normal user with sudo administrator privileges.
Install React on Ubuntu 20.04
Step 1 – Keep the server up to date
# apt update -y && apt upgrade -y
Step 2 – Install NodeJS and NPM
Install the latest stable release of NodeJS.
# curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash –
# apt-get install -y nodejs
Verify the installation is successful.
# node -v && npm -v
Output:
v15.9.0
7.5.4
Step 3 – Install create react app
In this article, we’ll use create-react-app tool. It is easiest and finest tool with production grade configurations pre-built. It is a comfortable environment for learning React, and is the best way to start building a new single-page application in React.
# npm install -g create-react-app
Verify the installation:
# create-react-app –version
Output:
4.0.2
Step 4 – Deploy React application
Create react applicaiton using following command:
# npx create-react-app my-app
Start development server
Once you’ve installed a React application, go to the root directory of your project and start the development server using following command:
# cd my-app
# npm start
You can now view my-app in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.0.102:3000
Build
Bundles the app into static files for production. Run following command:
# npm run build
That’s it. The installation has been completed successfully.
In this article, we have seen how to install React on Ubuntu 20.04.