create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

how i can run react program in vs code

Open SeHrBiz opened this issue 1 year ago • 7 comments

SeHrBiz avatar Jul 15 '24 20:07 SeHrBiz

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.

arashghezavati avatar Jul 18 '24 01:07 arashghezavati

CMD in vs code terminal :- npm run start

bharat407 avatar Jul 20 '24 11:07 bharat407

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

harish00506 avatar Jul 21 '24 14:07 harish00506

  1. install node js and npm
  2. install vs code from browser
  3. open terminal and type command { npx create-react-app my app }
  4. cd my app
  5. npm start

now your app is running on browser

jatintyagi1 avatar Jul 25 '24 10:07 jatintyagi1

To run a React program in Visual Studio Code (VS Code), follow these steps:

  1. 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.

  1. Open the Project in VS Code

  2. Open VS Code.

  3. Click on File > Open Folder... and navigate to your React project directory (e.g., my-react-app).

  4. Select the folder to open it in VS Code.

  5. Install Dependencies

If you cloned an existing React project or downloaded one, you need to install the necessary dependencies:

  1. Open a terminal in VS Code by going to View > Terminal.

  2. Make sure you're in the root directory of your React project.

  3. Run the following command to install dependencies:

    npm install
    
  4. Run the React Application

To start the React development server:

  1. In the terminal, make sure you're in the root directory of your React project.

  2. 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.

Xhz0729 avatar Aug 29 '24 00:08 Xhz0729

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!

wandanamaddumage avatar Sep 05 '24 08:09 wandanamaddumage

⚙️ 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.

isachinpnr avatar Oct 09 '25 11:10 isachinpnr