Tutorial on Setting Up the Development Environment
Hello students! In the previous module, we learned about the overview of React, Importance and usage in web development, and the main concepts and terminology of React.
In this topic, we will learn how to configure the development environment to create React applications.
Requirements
To set up the development environment for React, you will need the following:
- A computer with Windows, macOS, or Linux operating system
- A text editor or Integrated Development Environment (IDE)
- A package manager, such as npm or yarn
Installing Node.js and npm
Node.js is an open-source JavaScript platform that allows running JavaScript outside the browser.
npm is a package manager for Node.js.
To install Node.js and npm, follow these steps:
- Visit the Node.js website and download the installer for your operating system.
- Run the installer and follow the on-screen instructions.
After installation, you can check if Node.js and npm are installed by running the following commands in the terminal:
node -v
This command should return the installed version of Node.js.
npm -v
This command should return the installed version of npm.
Installing React
React can be installed using npm or yarn.
To install React using npm, run the following command in the terminal:
npm install react
To install React using yarn, run the following command in the terminal:
yarn add react
After installation, you can check if React is installed by running the following command in the terminal:
npm list --depth 0 | grep react
This command should return the react
package.
Creating a React Project
To create a React project, you can use the create-react-app
command.
This command will create a new React project with all the necessary files and dependencies.
To create a React project using create-react-app
, run the following command in the terminal:
npx create-react-app my-app
This command will create a new directory called my-app
with all the necessary files and dependencies.
To start the project, navigate to the my-app
directory and run the following command:
npm start
This command will start the React development server and open the application in the browser.
Conclusion
In this tutorial, you learned how to set up the development environment to create React applications.
Now, you can start building your own React applications.