What is Node.js?

Node.js is a runtime: a program that runs JavaScript outside the browser. Its engine (the part that runs the code) is V8, from Google Chrome. The language is…

So far your JavaScript has run inside a browser tab. There it can change the text, colours and buttons on a page. But JavaScript in the browser can't read a notes.txt file on your laptop, and it can't keep answering messages after the tab is closed. The browser keeps it locked inside the page on purpose.

Node.js is a program that runs JavaScript outside the browser: on your laptop, in the terminal, and on a server. The terminal is the window where you type commands. A server is a computer that stays on to answer requests from the internet. The language is still JavaScript. The tools around it are different. In the browser, JavaScript can change the page. In Node.js, JavaScript can read files on disk and answer requests from the internet.

Runtime: what runs your code

JavaScript code can't run on its own. It needs a runtime: a program that reads your code, runs it, and provides built-in tools. The browser is a runtime. Node.js is a runtime too.

Inside every runtime there is an engine: the part that runs the JavaScript code. Node.js uses V8, the engine Google built for the Chrome browser. Ryan Dahl created Node.js in 2009. He took V8 out of Chrome and added tools for files, networking and processes (running programs). So Node.js is not a new language. It is not a framework either (a set of ready-made code for organising an app).

Same language, different tools

if, for, functions, arrays and objects work exactly the same in the browser and in Node.js. What differs is the built-in objects and modules that are available. A module is a set of ready-made functions with one name, such as fs.

Browser Node.js
Web page document, window none
Info about the running program none process
Read and write files can't the fs module
Make a server can't the http module
fetch() yes yes (since Node 18)

process is a built-in Node object that holds info about the program that is running: the Node version, the folder the program was started in, and the arguments typed in the terminal. In Node, typeof process gives "object". The browser has no process, so in the browser it gives "undefined".

The reverse is true too: Node has no document, because a terminal has no page to change.

Your first file: node app.js

Install the LTS version of Node.js from nodejs.org. LTS (Long Term Support) versions are maintained for years. In November 2026, the newest LTS is Node 26, and Node 24 and 22 are still maintained. Then run these commands in the terminal, one line at a time:

node --version
# v24.18.0

mkdir notes-api
cd notes-api
npm init -y

The first line prints the version of Node that is installed. The # line is an example of the answer, so don't type it. mkdir creates a new folder, and cd moves into that folder.

npm is a project management tool that comes installed with Node. npm init -y creates the file package.json, your project's ID card. It holds the project's name, its version and its scripts (short commands for that project). -y means answer "yes" to every question npm asks. Throughout this track we build this project into a small notes API. An API is a program on a server that answers requests with data.

Create the file app.js in the notes-api folder:

console.log("Hello from Node.js!");
console.log(process.version);

Run it with node followed by the file name:

node app.js

The result:

Hello from Node.js!
v24.18.0

When the code needs browser tools

Add the line console.log(document.title); as line 3, then run the file again. Now you get an error:

Hello from Node.js!
v24.18.0
/home/budi/notes-api/app.js:3
console.log(document.title);
            ^

ReferenceError: document is not defined
    at Object.<anonymous> (/home/budi/notes-api/app.js:3:13)
    ...

Node.js v24.18.0

Read the error message from the top: the file and line number, the line of code with the problem, a ^ under the wrong word, then the error's name and message. document is not defined means the name document doesn't exist in this runtime. The first two lines were already printed. The program only stopped at line 3, the line with the error.

What Node.js is used for

Other options you will meet in tutorials:

Option When to pick it
npm Node's built-in package manager. This track uses npm because it is installed together with Node.
pnpm or yarn Replacements for npm. pnpm is faster and saves disk space, because the same package is stored only once.
Deno or Bun Other runtimes, not Node. Both run TypeScript (JavaScript with data types added) directly, and most npm packages work too. This track uses Node because it is the most used.

Node 22.18 and later can also run a TypeScript file directly: node app.ts. The types are only removed, not checked, so const age: number = "seventeen" still runs.

⚠️ First-day mistakes with Node

TL;DR: Node.js is a runtime: a program that runs JavaScript outside the browser. Its engine (the part that runs the code) is V8, from Google Chrome. The language is the same as in the browser, but the built-in tools differ. Node has process (info about the running program), fs (files) and http (making a server that answers requests from the internet), but no document or window. So typeof process gives "object" in Node and "undefined" in the browser. Install an LTS version (a version maintained for years, in November 2026: 26, 24 or 22). Create a project with npm init -y (npm: a project tool that comes with Node), which makes the file package.json. Then run a file with node app.js in the terminal (the window where you type commands). process.version holds the version of Node that is running.

⚡ JavaScript outside the browser

Guess first: is Node.js a new language, a framework (a set of ready-made code for organising an app), or something else?

Neither. Node.js is a runtime: a program that runs JavaScript outside the browser. Its engine (the part that runs the code) is V8, taken from Chrome.

Meaning: The language is still JavaScript, but the tools around it are different. In the browser, JavaScript changes the page. In Node.js, JavaScript can read files on disk and answer requests that come from the internet.

⚡ Your first file

Write:

console.log("Hello from Node.js!");
console.log(process.version);

Meaning: Save this code as app.js, then run it from the terminal (the window where you type commands) with node app.js. In Node, console.log prints to the terminal. process is a built-in Node object, and process.version holds the version of Node that is running, for example v24.18.0.

⚡ process yes, document no

Guess first: in Node, what does typeof process give?

"object". process is a built-in Node object that holds info about the running program. The browser has no process, so in the browser it gives "undefined".

Meaning: The reverse is also true: Node has no document or window, because a terminal has no web page. If your code uses document in Node, the program stops with ReferenceError: document is not defined.

What you will learn