How to Run Code in VS Code and the Browser: Python, JavaScript, HTML, and React
Articles
7 min

How to Run Code in VS Code and the Browser: Python, JavaScript, HTML, and React

Dora Gurova
By
Dora Gurova
Updated:
May 18, 2026

Running code depends on what kind of file you have. Python files run with Python, JavaScript can run in Node.js or in the browser, HTML opens in a browser, and JSX or React code usually runs inside a React project with a development server. One of the biggest beginner mistakes is assuming every file runs the same way just because you're using VS Code.

Quick fixes

  • python is not recognized → Python may not be installed or added to PATH
  • node is not recognized → install Node.js
  • JSX gives syntax errors → you probably opened a file instead of a React project
  • HTML opens but nothing happens → JavaScript may not be connected correctly
  • VS Code has no Run button → VS Code is an editor, not the runtime

What it actually means to "run code"

Code is just text until something executes it.

VS Code itself does not execute most code. It helps you write and manage files, but something else actually runs them.

For example:

  • a .py file needs Python
  • a .js file may need Node.js or a browser
  • an .html file needs a browser

That is why pressing "Run" works sometimes and completely fails other times.

The 4 environments beginners confuse most

Think of VS Code as your workspace. It can launch tools, but it still depends on things installed on your machine.

How to run Python code

Run a Python file from the terminal

Open Terminal and run:

python file.py

On some systems:

python3 file.py

Example:

python hello.py

If the script prints:

print("Hello")

you should see:

Hello

Run Python code in VS Code

Install Python and the VS Code Python extension.

Open your file.

Look in the top-right corner and click Run.

VS Code will run the currently selected Python interpreter.

If you see strange behavior, check the selected interpreter:

Python: Select Interpreter

using the Command Palette.

Using the official Python workflow is usually more reliable than generic Run extensions.

Use the Python REPL for quick tests

Open terminal:

python

or:

python3

You can type code immediately:

>>> 2+2
4

This is useful for quick testing.

Common Python problems

python not recognized

Likely cause:

Python is missing or not in PATH.

Fix:

Install Python and restart your terminal.

Wrong interpreter selected

Likely cause:

VS Code chose a different Python version.

Fix:

Select another interpreter.

No output appears

Likely cause:

You ran code in the wrong folder.

Fix:

Check your working directory.

How to run JavaScript code

JavaScript confuses beginners because there are multiple execution paths.

Run JavaScript with Node.js

Install Node.js.

Then run:

node file.js

Example:

console.log("Hello");

Run:

node app.js

Output:

Hello

Run JavaScript in the browser

Create:

<script>
console.log("Hello")
</script>

Open Developer Tools and check Console.

How to tell which one your file needs

Browser JavaScript often uses:

document.querySelector()
window
alert()

Node.js code often uses:

require()
fs
process

Mixing these environments causes many beginner issues.

For example:

document.querySelector()

works in browsers but fails in Node.

How to run HTML code

HTML does not really run the same way Python does.

Browsers render HTML.

Open an HTML file in a browser

Create:

<!DOCTYPE html>
<html>
<body>
<h1>Hello</h1>
</body>
</html>

Save:

index.html

Double-click the file.

Or right-click:

Open with browser.

Add JavaScript to HTML

Example:

<script src="app.js"></script>

Place it before:

</body>

This helps avoid issues where JavaScript runs before page elements load.

When to use browser console

Developer Tools let you test JavaScript quickly without editing files.

Open:

  • Chrome DevTools
  • Firefox Developer Tools

Then use Console.

How to run a .js file in VS Code

What you need before VS Code can run JS

Install Node.js first.

Check:

node --version

Run a JS file from integrated terminal

Open:

Terminal → New Terminal

Then:

node file.js

Integrated terminal is often simpler than extensions.

Use Run and Debug

Press:

F5

or open:

Run and Debug

Choose Node.js.

This is useful when debugging larger projects.

How to run a .jsx file in VS Code

Why JSX does not usually run by itself

JSX is not usually a standalone execution target.

Beginners often try:

node app.jsx

and get syntax errors.

What JSX actually needs

JSX usually gets transformed into regular JavaScript.

That transformation often happens using React tooling.

Think:

React project

not:

single script file

When a .jsx file is part of a React app

Usually your file structure looks like:

src/
 App.jsx
 main.jsx

Then the project runs through the React development server.

How to run a React app in VS Code

Check Node.js and npm

Run:

node --version

npm --version

Open or create a React project

Open project folder:

my-react-app

Install dependencies

If needed:

npm install

Start development server

Usually:

npm start

Some projects use:

npm run dev

Check:

package.json

for scripts.

Open the app in the browser

You may see:

localhost:3000

or:

localhost:5173

Open that address.

Debug React in VS Code

Use:

F5

or browser DevTools.

What to do after you can run code

Once you know how to run scripts and frontend code, the next challenge is often building something people can actually use. Teams quickly move from simple files toward dashboards, admin panels, internal tools, and workflow interfaces connected to real systems.

That is where tools like UI Bakery become useful. Instead of manually wiring every screen, teams can build internal apps faster on top of databases and APIs.

How do I run Python code in VS Code?

Install Python and the Python VS Code extension, open your file, and press Run or execute:

python file.py

How do I run a JavaScript file in VS Code?

Install Node.js and run:

node file.js

from the integrated terminal.

Do I need Node.js to run JavaScript?

Not always. Browser JavaScript runs inside a browser. Standalone JavaScript often uses Node.js.

Can I run a JSX file directly in VS Code?

Usually no. JSX normally belongs inside a React project.

How do I run an HTML file with JavaScript?

Open HTML in a browser and connect JavaScript using:

<script src="app.js"></script>

Why does VS Code say python or node is not recognized?

The runtime is likely missing or not configured in your system PATH.