Skip to content
wannacode

Getting your computer ready

Problem

What you need

To write and run programs, you need two things:

  1. Node.js: the node program that runs JavaScript outside the browser, and the npm command for ready-made libraries.
  2. An editor for your code. You could write a program in Notepad, but an editor for programmers colors the code, gives you hints and shows errors as you type.

If you do not have a computer you can install programs on yet, an online editor is enough for the first few days: search the web for online JavaScript. The tasks from the "Language basics" module work there too. For the bigger programs later on, you will need an installation.

The idea

Install Node.js 22

We use Node.js 22. This is a long-term support version (LTS): it gets fixes until April 2027. Download it from nodejs.org, in the Download section. If a newer LTS version is offered there (24, for example), it works too: everything in the course runs on it.

  • Windows and macOS: download the installer and run it.
  • Linux: the nodejs package from your system is often an old version. On nodejs.org, in the Download section, there are commands for your system.

Check. Open a new terminal (on Windows: PowerShell or Command Prompt) and type:

Terminal
node --version

You should see the version number. The numbers after 22 may be different:

v22.11.0

The idea

Choose an editor

Two good options:

  • Visual Studio Code: it understands JavaScript on its own, without extensions. Open its terminal (Terminal → New Terminal) and run your programs from there.
  • WebStorm from JetBrains: an editor made specially for JavaScript. It is free for non-commercial use, which includes learning.

Which editor you choose does not matter much. What matters more is that you get used to one and use it every day.

See it

Your first program on your computer

Make a folder for the course, and in it a file named shop.js with this content:

shop.js
console.log("Hello!");
Output
Hello!

That is the whole program: one line, with nothing around it. In the terminal, go to the folder (cd and the path to it) and run:

Terminal
node shop.js

Node.js checks the file, translates it and runs it right away. No other file appears in the folder.

More precisely, if you are curious
  • The node command without a file opens a mode where you type line by line and see the result right away. It is handy for trying out one line. You leave it with Ctrl+D or with .exit.
  • JavaScript runs in the browser too: press F12 and open the Console tab. You can try things line by line there as well, but in this course you run programs with Node.js.
  • If the Windows terminal shows question marks or odd symbols instead of characters such as € or é, the terminal is not set up for UTF-8. Type chcp 65001 and run the program again. Editors usually do not have this problem.

Try it

Change it and run it again

Add a second line that prints "Your computer is ready.", save the file and run the program again. You should see:

Output
Hello!
Your computer is ready.

If you see only "Hello!", the file most likely is not saved. Here is the whole program, in case you get stuck:

shop.js
console.log("Hello!");
console.log("Your computer is ready.");

Why a change you have not saved does not reach the program:

console.log("Hello!");
console.log("Your computer is ready.");
Step by step, in words
  1. The editor and the file on disk both have only the first line.
  2. You run node shop.js: Node.js reads the file on disk.
  3. You add a second line in the editor. The file on disk is still the old one.
  4. You run it without saving: you still get only "Hello!".
  5. You save (Ctrl+S): the editor writes the text to the file on disk.
  6. You run it again: now the program sees the second line too.

The idea

When it will not start

  • "'node' is not recognized…" (Windows) or "command not found" (macOS, Linux): the terminal cannot find Node.js. Close it and open a new one, because the old one does not see the changes from the installation. If it still does not work, run the installer again.
  • node --version shows an old version, such as v18: there is also an older installation on the computer. Install Node.js 22 from nodejs.org.
  • "Error: Cannot find module '…/shop.js'": you are running from the wrong folder, or the file has a different name. Go into the folder with shop.js (cd and the path to it).
  • SyntaxError or another message with a line number: Node.js has started and read the file, so the installation is fine. Compare your code with the example character by character.

In short

In short

  • You need Node.js 22 and an editor: VS Code or WebStorm.
  • node --version shows whether Node.js is installed.
  • node shop.js checks the file, translates it and runs it.
  • If the terminal cannot find the command, open a new terminal.

Next comes the lesson on how to solve a task before a single line of code is written.

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·