π οΈ ReactJS Environment Setup
π― Objective:
To set up a ReactJS development environment so you can build, run, and test React applications on your local system.
β Step 1: Prerequisites
Before installing React, you need the following software installed:
πΉ 1. Node.js
- React uses Node.js for running scripts and installing packages using npm (Node Package Manager).
- It also includes
npm
, which is required to install React packages.
π§ Install Node.js:
- Visit: https://nodejs.org/
- Download LTS version (Long Term Support).
- Install using the wizard.
π Check Installation:
node -v # Shows Node.js version
npm -v # Shows npm version
β Step 2: Install Create React App
Create React App
is a tool that sets up a new React project with a ready-to-use development environment.
π₯ Install it (one-time globally):
npm install -g create-react-app
β This command installs a global utility to quickly scaffold new React projects.
β Step 3: Create a New React Project
Now, letβs create a React app called myapp
.
npx create-react-app myapp
πΉ This command:
- Sets up the project structure
- Installs all required dependencies
- Adds React boilerplate code
β
npx
(comes with npm) ensures you’re using the latest version of create-react-app
without installing it globally.
β Step 4: Navigate to Project Directory
cd myapp
This is now your project root folder, where all React files reside.
β Step 5: Start the Development Server
To start the app:
npm start
π This will:
- Compile the code
- Open your app in the browser (usually at http://localhost:3000)
- Show a default React welcome page
β React Folder Structure Overview
myapp/
βββ public/
β βββ index.html # Single root HTML page
β
βββ src/
β βββ App.js # Main App Component
β βββ index.js # Renders App component to DOM
β βββ components/ # (You create this folder for reusable components)
β
βββ package.json # Project configuration and dependencies
βββ node_modules/ # All installed libraries
π¦ package.json β React App Configuration
This file stores:
- Project name and version
- Installed dependencies (React, React DOM)
- Scripts like
start
,build
, andtest
π§ Important Commands:
Command | Purpose |
---|---|
npm start | Run development server |
npm run build | Prepare production build |
npm test | Run tests (if written) |
npm install <pkg> | Install new packages (like Bootstrap, Axios) |
π§ͺ Optional Tools to Enhance Workflow
Tool | Purpose |
---|---|
VS Code | Recommended code editor |
React Developer Tools (Chrome/Firefox) | Inspect components in browser |
Git | Version control (for teamwork) |
Postman | Test APIs (for React-API apps) |
β Recap of Setup Steps
Step | Action |
---|---|
1οΈβ£ | Install Node.js + npm |
2οΈβ£ | Use npx create-react-app myapp |
3οΈβ£ | Navigate to project folder |
4οΈβ£ | Run npm start to launch dev server |
5οΈβ£ | Build components and start coding! |
π° Additional Tips for MCA Students
- Always create reusable components (
Header
,Footer
, etc.). - Practice passing props and managing state.
- Learn React Router for building multipage apps.
- Explore Hooks (
useState
,useEffect
) for functional components. - Use Bootstrap or Material UI for designing UI quickly.