Setting Up JavaScript

Updated · 6 min read
easyES2026javascriptsetupnodejsdevtoolsvscode

To write JavaScript you need two things: a place to type code and a place to run it. This lesson sets up the three places professionals use every day: the browser console for quick experiments, Visual Studio Code for real files, and Node.js for running JavaScript outside the browser. The whole setup is free and takes about fifteen minutes.

In One Minute

  • The browser console runs a line of JavaScript instantly. Open it with F12 (Windows) or Cmd+Option+J (Chrome on a Mac).
  • Visual Studio Code (VS Code) is a free editor; save code in .js files and link them from an .html page.
  • Node.js runs .js files from the terminal with node file.js. This course uses Node.js 26, the current LTS (long-term support) version.
  • Every example in this course also has a Try it button, so you can start before installing anything.

The Browser Console

Every browser has developer tools (DevTools) with a Console panel. It is a scratch pad: type an expression, press Enter, see the result.

BrowserWindows / LinuxMac
Chrome, EdgeF12 or Ctrl+Shift+JCmd+Option+J
FirefoxF12 or Ctrl+Shift+KCmd+Option+K
Safari(enable it first)Turn on Show features for web developers in Settings, Advanced; then Cmd+Option+C

Try typing these lines one at a time:

Console
2 + 3
"Fee Tracker".toUpperCase()
console.log("Hello, Srihitha")

The console shows 5, then 'FEE TRACKER', then prints Hello, Srihitha followed by undefined. That last undefined surprises people: the console shows the value of every expression you type, and console.log(...) prints its message but has no value of its own.

An Editor and a Web Page

For anything longer than a line, write files. Install Visual Studio Code from code.visualstudio.com, then create a folder named fee-tracker with two files:

index.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Fee Tracker</title>
    <script src="app.js" defer></script>
  </head>
  <body>
    <h1>Fee Tracker</h1>
  </body>
</html>
app.js
console.log("Fee Tracker loaded");

Double-click index.html to open it in your browser, then open the console: you see Fee Tracker loaded. Each time you change app.js, save and reload the page.

A small extension makes this faster: Live Server (or any "live preview" extension) serves the folder and reloads the page whenever you save. Opening files directly (a file:// address) works for this lesson, but later lessons that use fetch or modules need a real local server, because browsers block those features for local files.

Node.js: JavaScript in the Terminal

Node.js is a runtime that runs JavaScript outside the browser. You will use it to run examples, scripts and tests.

  1. Go to nodejs.org and download the LTS version. As of November 2026 that is Node.js 26 (Active LTS since October 28, 2026, supported until April 30, 2029).
  2. Run the installer. On macOS you can instead use a version manager such as nvm, which lets you switch versions per project.
  3. Check the installation in a terminal:
Terminal
node --version
Output
v26.13.1

Your number may be newer than v26.13.1; any v26 is fine. Now run a file. Save this as hello.js:

hello.js▶ Try it
const student = "Advitha";
console.log(`Hello, ${student}! Node.js is ready.`);
Output
Hello, Advitha! Node.js is ready.

Then run it from the folder that contains it:

Terminal
node hello.js

Two Useful Node.js Habits

  • node --watch hello.js reruns the file every time you save it, like Live Server for scripts.
  • node on its own opens the REPL (read, evaluate, print loop), which works like the browser console. Type .exit or press Ctrl+D twice to leave.

Reading Your First Error

Everyone's code fails. The skill is reading the error. Run this:

typo.js▶ Try it
const fee = 120;
console.log(Fee);
Output
ReferenceError: Fee is not defined

The message has two parts: the error type (ReferenceError, meaning a name that doesn't exist) and a description (Fee is not defined). JavaScript names are case-sensitive, so Fee and fee are different names. In the browser console and in Node.js, the error also shows the file name and line number, so you know exactly where to look.

Error typeUsually means
SyntaxErrorThe code isn't valid JavaScript: a missing bracket, quote or comma
ReferenceErrorA name that doesn't exist: a typo, or a variable used outside its scope
TypeErrorA value used the wrong way: calling something that isn't a function, reading a property of undefined

Common Mistakes

Running Node.js on the wrong folder. node hello.js looks in the terminal's current folder. If you see Cannot find module, use cd to move to the folder that contains the file.

Forgetting to save or reload. The browser runs the file as it was when the page loaded. Save in the editor, then reload the page (or use a live preview extension).

Installing an odd-numbered or end-of-life Node.js. Node.js 25 reached end of life on June 1, 2026 and gets no security fixes. Use the LTS line.

Typing node hello.js inside the Node.js REPL. That is a terminal command. If you see a > prompt, you are in the REPL; leave it with .exit first.

Practice

Challenge: Create receipt.js that stores a student name and a fee in two variables, then prints Receipt for Navika Anamaneni: $120. Run it with Node.js, then change the fee and run it with node --watch to see it rerun on save.

Show solution
receipt.js▶ Try it
const name = "Navika Anamaneni";
const fee = 120;
console.log(`Receipt for ${name}: $${fee}`);
Output
Receipt for Navika Anamaneni: $120

Quick check: Setting up JavaScript

3 questions
1In the browser console, why does console.log("Hi") show undefined after printing Hi?
2Which Node.js version should you install for this course?
3What does a ReferenceError usually mean?

Key Takeaways

TaskHow
Open the consoleF12, or Cmd+Option+J in Chrome on a Mac
Check Node.jsnode --version
Run a filenode hello.js
Rerun on savenode --watch hello.js
Open the REPLnode (leave with .exit)

Was this tutorial helpful?

Lesson 3 of 139