Install Node.js and use the terminal

Install Node.js and VS Code, learn the handful of terminal commands you need, and run your first program.

Module 1: Back-end foundations · Lesson 2 of 26 · 15 min read · Free

Install

  1. Node.js — from nodejs.org, download the LTS version (22 or newer) and install with the default options. npm (the package manager) comes with it.
  2. VS Code — from code.visualstudio.com, if you don't already have it.
  3. In VS Code, install the REST Client extension (by Huachao Mao) — you'll use it to send requests to your APIs.

The terminal

Back-end developers live in the terminal. In VS Code: Terminal → New Terminal.

The terminal in VS Code
CommandDoes
node -vshows your Node.js version — check it's 22 or newer
cd foldergo into a folder (cd .. goes up)
ls (or dir on old Windows)list files
node file.jsrun a JavaScript file
npm installinstall the packages listed in package.json
Ctrl+Cstop a running program (like a server)
↑repeat the previous command

Your first Node.js program

  1. Download be-course-files.zip (below), unzip it, and open the folder in VS Code (File → Open Folder).
  2. In the terminal, run:
node 01-node-basics/hello.js Ada

You'll see a greeting with your name and today's date. Look at the code: process.argv[2] reads the word you typed after the file name. That's how command-line tools receive input.

  1. Run npm install once in that folder. It downloads Express into a node_modules folder (you'll need it from Module 3).

Check yourself

Answer in your head first, then open each question to see the answer and why.

  1. Which command shows your Node.js version?

    • A node -v
    • B npm start
    • C cd node
    • D version node
    Show the answer

    A) node -v — node -v (or --version) prints the installed version.

  2. How do you stop a running server in the terminal?

    • A Ctrl+C
    • B Ctrl+S
    • C Close the file
    • D Type stop
    Show the answer

    A) Ctrl+C — Ctrl+C interrupts the running program.

  3. Why must prices and totals be calculated on the server?

    • A Users can change anything that runs in their browser or app
    • B Servers are better at maths
    • C Browsers can't multiply
    • D It's faster
    Show the answer

    A) Users can change anything that runs in their browser or app — Never trust values the client could have changed.

More free lessons: What the back end does · Asynchronous code: promises and async/await · HTTP: requests, responses and status codes · Designing a REST API · Designing tables and relationships · Storing passwords safely · Automated tests and project structure