Day 2: Setting Up Your Development Environment

Day 2: Setting Up Your Development Environment

Introduction

Welcome back to Day 2 of our 30-day blog series on React.js! Now that we have a basic understanding of what React.js is, it's time to set up our development environment so we can start building React applications.

Installing Node.js and npm Node.js is a JavaScript runtime environment that allows you to run JavaScript on the server-side. npm (Node Package Manager) is a package manager for Node.js that allows you to install and manage dependencies for your projects.

To install Node.js and npm, follow these steps:

Download Node.js: Visit the official Node.js website (https://nodejs.org) and download the latest version of Node.js for your operating system.

Install Node.js: Run the installer and follow the on-screen instructions to install Node.js on your computer.

Verify Installation: After installation, open a terminal or command prompt and run the following commands to verify that Node.js and npm are installed:

node -v
npm -v

These commands should output the installed versions of Node.js and npm, respectively.

Setting Up a New React Project Once Node.js and npm are installed, we can use the create-react-app tool to set up a new React project quickly.

To create a new React project, open a terminal or command prompt and run the following command:

npx create-react-app my-react-app

Replace my-react-app with the name of your project.

This command will create a new directory called my-react-app with a basic React project structure and all the necessary dependencies installed.

Running Your React Application Once the project is created, navigate to the project directory and start the development server by running the following command:

cd my-react-app
npm start

This command will start the development server and open your default web browser to http://localhost:3000, where you can see your React application running.

In this post, we learned how to set up our development environment for React.js by installing Node.js and npm and creating a new React project using create-react-app. Now that our environment is set up, we're ready to start building React applications!

Stay tuned for tomorrow's post, where we'll dive into understanding JSX, React's syntax extension that allows us to write HTML-like code within JavaScript.

Did you find this article valuable?

Support Tech Blog by becoming a sponsor. Any amount is appreciated!