Free lesson · What JavaScript Is, and Running Your First Program

Installing Node and an editor

The console is fine for one-liners and hopeless for anything you want to keep. For real work you need two things: somewhere to write files, and something to run them.

An editor

Install Visual Studio Code from code.visualstudio.com. It is free, it runs everywhere, and it is what most JavaScript developers use. Any editor works — but if you have no preference yet, take the one with the most help available.

A word on what an editor is not: it does not run your code. It is a text editor that happens to colour your code and notice some mistakes. Running is a separate step.

Node

Install Node.js from nodejs.org. Take the version labelled LTS — long-term support, the boring dependable one. This course assumes Node 20 or later.

Then open a terminal and check it worked:

node --version

You should see something like v20.19.5. If instead you see command not found, Node is either not installed or your terminal has not noticed yet — close the terminal, open a new one, and try again before assuming the worst.

Running a file

Make a folder for this course, and inside it a file called hello.js. Put this in it:

console.log("Hello from a file");
console.log(2 + 2);

Save it. In the terminal, move into that folder and run:

node hello.js

Both lines print, in order, top to bottom. That ordering is worth noticing now because section 10 is largely about the cases where it stops being true.

node hello.js must be run from the folder the file is in, or with a path to it. cannot find module '/home/you/hello.js' means Node looked exactly where you told it and found nothing — almost always the wrong folder, not a broken installation. Run ls (or dir on Windows) and check the file is listed.

This is one lesson of 60

JavaScript Foundations: The Language, Explained Properly continues from here — 4 lessons are free to read like this one, and the rest come with the course. Enrolled readers also get an AI tutor that has read the lesson they are on.

See the full course