React JS – create new react application using Create-react-app
If you are looking forward to learn react JS or facing difficulties for creating new React application this post is for you guys only.
Today we will look how can we create new react application. To create new react application here are the prerequisites.
We need to have node install in our local system if you have not installed node you can download the latest version of node from here and install respective version in your system.
Create new React application using create-react-app
To create new react application a tool/NPM package create-react-app was created by great react engineering team at Facebook.
Now we will learn how we can create new React application by this tool.
Step 1: install create-react-app in your local system globally using below command.
npm install -g create-react-app
Once package is installed successfully you will get message like below.
Now we have create-react-app installed globally in local system so we can create new react application.
Use below command to create new react application.
It will install react, react-dom, react-scripts.
Once project is created successfully it will show success message. It also shows some npm commands to run newly created react application.
Go into the project’s folder from CLI and execute command to run application.
cd react-demo-app npm start
When we run command npm Start it will create development server and run our react application.
By default react application is running on PORT 3000 but if you want to run application on different port then you can define port number on which you want to run application.
Once application compiled successfully you will get success message and URL on which you can check the output of your react application.
Go to browser and hit URL http://localhost:3000. You will see the output of your application.
Here we didn’t change port we are using the default port number else PORT number will be used which you given at time of npm start.
React application will run on this port till the development server is open which was created at time of running npm start. when you close CMD development server will be stop and application will stop on port 3000.
Also when you want to stop development server you can use ctrl+c .
In this way you can create new react application using create-react-app npm package.
Hope this post will help you guys for create new react application.
Happy Hackoding (Hacking + coding). Cheers 🙂