Elemental SystemsSilicon · Boards · Software

Set Up Your Language · 1 of 14

Setting Up JavaScript (Node.js)

JavaScript is the language web browsers understand: every interactive web page uses it. Node.js is a free program that lets JavaScript run on your own computer, outside the browser. Installing Node.js also gives you npm, a tool for downloading add-ons that other people have written.

Set-up: EasyOfficial source: nodejs.orgFile ending: .js

New to all this? Read Before you start on the main page first: it shows how to open Terminal, make a folder for your code, and see file name endings. It takes five minutes and prevents most problems.

1 What to download, and from where

Download only from nodejs.org, the official Node.js website, run by the OpenJS Foundation. Other download sites can bundle unwanted software.

  1. Go to nodejs.org and open the Download page.
  2. Pick the version marked LTS (Long-Term Support). LTS means it is the stable version that gets fixes for years; the other one is newer but changes more often.
  3. Under the ready-made installers, choose Windows Installer (.msi) for x64. (If your computer has an ARM processor, such as some Surface laptops, choose ARM64.)

2 Install it on Windows

  1. Open the downloaded file (it is in your Downloads folder, named like node-v24.x.x-x64.msi).
  2. A window titled Node.js Setup opens. Click Next.
  3. Tick I accept the terms in the License Agreement and click Next.
  4. Keep the suggested folder and click Next. On the Custom Setup screen, change nothing and click Next. (It already includes "Add to PATH", which lets you type node in any Terminal.)
  5. On the screen about Tools for Native Modules, leave the box unticked. Beginners do not need it, and it installs a lot of extra software.
  6. Click Install. If Windows asks "Do you want to allow this app to make changes to your device?", click Yes. Click Finish when it is done.

3 Check that it worked

Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. Then type this and press Enter:

node -v
npm -v

What you will see: Two version numbers. Yours will probably be different, and that is fine: any numbers mean it worked.

v24.11.1
11.6.2

If you see an error such as "is not recognized" instead, look at the common mistakes at the bottom of this page.

4 Write and save your first program

A program is just a text file. You can write it in Notepad, which comes with Windows. (Later you may like the free Visual Studio Code editor from code.visualstudio.com, which colours the code and helps spot mistakes.)

  1. Open Notepad (press the Windows key, type Notepad, press Enter).
  2. Type the program below, or click Copy and paste it in with Ctrl + V. Every symbol matters, so copy it exactly.
    console.log("Hello, World!");
  3. In Notepad choose File → Save as. Go to your C:\code folder. Set Save as type to All files (*.*), type the file name hello.js exactly as shown, including the dot and the ending, and click Save.

console.log means "print this on the screen". The text inside the quotes is what gets printed.

Do not use Word. Word saves extra formatting and changes straight quotes " into curly ones “ ”, which no programming language accepts.

5 Run it and see the result

Open File Explorer, go into your C:\code folder, right-click an empty part of the window and choose Open in Terminal. (More ways to open Terminal.) If Terminal was already open from the check above and is in another folder, type cd C:\code and press Enter.

Type this and press Enter:

node hello.js

What you will see: the words below on a new line. That is your program running.

Hello, World!

Congratulations: you have written and run a JavaScript program.

6 Common beginner mistakes and how to fix them

Error messages look alarming but are usually precise: read the first line, and look for a line number. If you are stuck, copy the whole error message and paste it into an AI assistant along with your code, and ask what it means.

'node' is not recognized as an internal or external command

Why: Windows cannot find the program. Either the Terminal was open before you installed it, or the program's folder is not on the PATH (the list of folders Windows searches for commands).
Fix: Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. If it still fails, restart the computer, then check the folder is on the PATH (how to check and add it).

Error: Cannot find module 'C:\code\hello.js'

Why: Node cannot find the file. Either the Terminal is in a different folder, or the file was saved as hello.js.txt.
Fix: type dir and press Enter to list the files in this folder. If you see hello.js.txt, see how to show file name endings and rename it. If you do not see the file at all, open Terminal in the right folder.

Uncaught SyntaxError after typing node hello.js

Why: you typed node on its own first, which opened Node's interactive prompt (a > sign), and then typed the command inside it.
Fix: press Ctrl + C twice to leave the prompt, then type node hello.js as one line.