To create a new React project, we can use create-react-app
, a popular tool that sets up a new React project with all the necessary configurations and dependencies.
What is the difference between npm and npx?
npm :
It helps to install packages separately.
This package manager manages and shares the packages for React or Angular.
It is free to use.
npx :
With this, we can install every useful or needed project-related package at a time.
It will help to install all the packages at once. So, we don't need to install every time between projects.
NPX is a package executer.
Step - 1
:
Install create-react-app globally. Open your terminal and run the following command.
npm install -g create-react-app
Step - 2
:
Now we should select the path where we want to create the project.
cd path/to/your/project/directory
Then, run the following command to create the project:
npx create-react-app my-react-app
Step - 3
:
Now, you can start the development server to see your React app in action. Run the bellow command:
npm start