how i can run react program in vs code
To run a React program in VS Code, first install Node.js from nodejs.org. Open VS Code, create a new React app using npx create-react-app my-app in the terminal, then navigate to the app folder with cd my-app. Install dependencies with npm install and start the app using npm start in the terminal.
CMD in vs code terminal :- npm run start
follow these steps to run react program in vscode install node from internet go to vs code open terminal type npx create-react-app my-app cd my-app npm start
your react app is running
- install node js and npm
- install vs code from browser
- open terminal and type command { npx create-react-app my app }
- cd my app
- npm start
now your app is running on browser
To run a React program in Visual Studio Code (VS Code), follow these steps:
- Set Up Your React Project
If you haven't already created a React project, you can use create-react-app to set it up:
npx create-react-app my-react-app
This will create a new React project in a directory called my-react-app.
-
Open the Project in VS Code
-
Open VS Code.
-
Click on
File>Open Folder...and navigate to your React project directory (e.g.,my-react-app). -
Select the folder to open it in VS Code.
-
Install Dependencies
If you cloned an existing React project or downloaded one, you need to install the necessary dependencies:
-
Open a terminal in VS Code by going to
View>Terminal. -
Make sure you're in the root directory of your React project.
-
Run the following command to install dependencies:
npm install -
Run the React Application
To start the React development server:
-
In the terminal, make sure you're in the root directory of your React project.
-
Run the following command:
npm start
This command will start the development server, and you should see output in the terminal showing that the server is running.
1. Install Node.js and npm
- Download and install Node.js (which includes npm).
- To check if they're installed correctly, run the following commands in your terminal:
node -v npm -v
2. Set Up a React Project
- Open a terminal in VS Code (Ctrl + ~) and navigate to the folder where you want to create your React project.
- Run the following command to create a new React app using create-react-app (a simple way to set up a React environment):
npx create-react-app my-app - Replace my-app with the desired name of your project.
3. Open the Project in VS Code
- Once the project is created, navigate into the project folder:
cd my-app - Then open the folder in VS Code:
code .
4. Start the Development Server
- In the terminal, run:
npm start - This will start the development server, and your React app will be accessible at http://localhost:3000 in your browser.
5. Make Changes and See Live Updates
- As you modify the code in VS Code, the browser will automatically reload and reflect the changes. This setup lets you develop and run React applications directly in VS Code!
⚙️ 1️⃣ Install Node.js
React requires Node.js and npm (Node Package Manager).
👉 Check if it’s already installed:
Open your VS Code terminal and run:
node -v npm -v
If both show version numbers — perfect. If not, install Node.js:
🧩 Install (on Kali/Ubuntu/Linux) sudo apt update sudo apt install nodejs npm -y
Optionally, install the latest version from Node’s website: 👉 https://nodejs.org
⚙️ 2️⃣ Create a New React App
You can use either Create React App or Vite (modern and faster). I’ll show both ways 👇
✅ Option 1 — Using Create React App (Simple) npx create-react-app my-react-app cd my-react-app npm start
That’s it 🎉 — it will open automatically in your browser at 👉 http://localhost:3000
✅ Option 2 — Using Vite (Recommended for speed) npm create vite@latest my-react-app
Then select:
React JavaScript
Now run:
cd my-react-app npm install npm run dev
This will start your React app at 👉 http://localhost:5173
⚙️ 3️⃣ Open in VS Code
You can open the project folder directly from terminal:
code my-react-app
(or open VS Code manually → File → Open Folder → choose your project).
🧠 4️⃣ Folder Structure (for reference) my-react-app/ ├── node_modules/ ├── public/ ├── src/ │ ├── App.js │ ├── index.js │ ├── components/ │ └── ... ├── package.json └── vite.config.js (if using Vite)
🧰 5️⃣ Run the Project Anytime
To start the React app again after closing VS Code:
cd my-react-app npm start
(for Create React App)
or
npm run dev
(for Vite)
💡 Optional (Useful VS Code Extensions)
ES7+ React/Redux/React-Native snippets → for fast React boilerplates.
Prettier → for auto code formatting.
React Developer Tools (browser extension) → for debugging components.