React JS is a popular JavaScript library for building user interfaces, particularly for single-page applications where you want a fast and dynamic user experience.
To install React JS on Ubuntu, you need to set up Node.js and npm (Node Package Manager) first, as React is a JavaScript library that relies on these tools. Here are the steps to install React JS on Ubuntu:
Step 1: Install Node.js and npm
Node.js and npm are essential tools for React development because they provide a convenient way to manage dependencies, run development servers, and execute various scripts and tasks related to the development and build processes of a React application. When you install React, you typically use npm to manage its dependencies and leverage Node.js for running development servers and build tools.
To install Node.js and npm, let’s first update the system;
sudo apt update
Now, let’s install Node.js and npm:
sudo apt install nodejs npm
Verify the installation by checking the version of Node.js and npm:
node -v
npm -v
Step 2: Install the Create React App tool
Create React App is a tool that sets up a new React project with a good default configuration. This should be a global installation using the npm command;
sudo npm install -g create-react-app
After installation, check the installed version:
create-react-app --version
If successfully installed, you should be able to see the following on your terminal;
root@host:~# create-react-app --version
5.0.1
Step 3: Create a new React app
Create a new React app by running the following command (replace “my-react-app” with your preferred project name):
npx create-react-app my-react-app
Change to the newly created app directory:
cd my-react-app
Step 4: Run the React app
Start the development server:
npm start
Open your web browser and go to http://localhost:3000
. You should see your new React app running.
Congratulations! You’ve successfully installed React JS on your Ubuntu system and created a new React app. You can now start building your React components and developing your application.