In this article, we’ll explain how to install React on Ubuntu 20.04.
This article will guide you with the installation process and deploying React site.
- 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
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
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.
On Your Network: http://192.168.0.102:3000
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.