Setting up a development environment for a React project involves several steps.
Install Node.js and npm:
Download and install Node.js from the official website. This also installs npm, the Node package manager.
If you are a Linux user, you can install this tool by using the terminal.
# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# download and install Node.js
nvm install 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.13.1`
# verifies the right NPM version is in the environment
npm -v # should print `10.5.2`
Create a new React project:
Open a terminal or command prompt and run the following command to create a new React project using Create React App:
npx create-react-app my-react-app
Replace my-react-app with your desired project name.