Install ReactJS on ubuntu 20.04
This article help you on how to install and create React Application on Ubuntu 20.04 system.
Step 1: Install nodejs
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
Also Read -> How to Install Apache Maven on Ubuntu 20 04
Next, install nodejs using apt command.
sudo apt install nodejs
once it is installed, you can check nodejs version.
ubuntu@ubuntu20:~$ node -v v14.16.1
you can also verify the NPM version by running the following command.
ubuntu@ubuntu20:~$ npm -v 6.14.12
Also Read -> How to Install CouchDB on Ubuntu 20 04
Step 2: Install Reactjs
you need to install the create-react-app tool to create a new project in React.
It is a command-line utility used to create a React Application.you can install it using the NPM.
npm install -g create-react-app
/usr/bin/create-react-app -> /usr/lib/node_modules/create-react-app/index.js + email@example.com added 67 packages from 25 contributors in 27.717s
Also Read -> How to Install Apache Tomcat 9 on Ubuntu 20 04
Step 3: create new project
Next, you can create new project with the following command.
Success! Created myreactapp at /root/myreactapp Inside that directory, you can run several commands: npm start Starts the development server. npm run build Bundles the app into static files for production. npm test Starts the test runner. npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back! We suggest that you begin by typing: cd myreactapp npm start Happy hacking!
Also Read -> How to Install Atom Text Editor on Ubuntu 20 04
Next, change the directory to myreactapp and start the application like below.
cd myreactapp npm start
Compiled successfully! You can now view myreactapp in the browser. Local: http://localhost:3000 On Your Network: http://192.168.0.123:3000 Note that the development build is not optimized. To create a production build, use npm run build.
once your application is ready, you can run '"npm run build" command to create production build of your React.js application.
That's it. now you have successfully installed Reactjs on ubuntu 20.04 system.
Also Read -> How to Install PHP 8 on Ubuntu 20 04