For ten years JavaScript could only live inside a tab. Writing a server, a backup script or a command-line tool called for another language.
Node.js removed that border by carrying the browser's engine somewhere else.
Definition
Node.js is a runtime that executes JavaScript outside the browser. It embeds Chrome's V8 engine and adds what a tab is not allowed to do: read files, open a port, launch other programs, read environment variables.
import { readFile } from "node:fs/promises";
const content = await readFile("invoices.json", "utf8");
const invoices = JSON.parse(content);
const total = invoices.reduce((sum, i) => sum + i.amount, 0);
console.log(`${invoices.length} invoices, ${total} euros`);The node: prefix marks a module supplied by the runtime itself, with nothing to install. The syntax is the everyday one: Array.reduce(), JSON and await behave exactly as they do in a browser. That last point is what makes the environment worth learning quickly, since the whole language transfers and only the surrounding library has to be discovered.
What changes, what stays
| Available in Node.js | Available in the browser |
|---|---|
| process, for arguments and environment | window, the global object of the page |
| node:fs, to read and write files | localStorage, for limited storage |
| node:http, to listen on a port | document and the tree of the page |
The language is identical on both sides: Array, Promise, class or Map do not change from one environment to the other. What differs is the set of objects the environment places around them.
One thread, never blocked
Node runs application code on a single thread. It holds up under load because slow operations, disk and network, are handed to the system and delivered back later by the Event loop, rather than waited on in place. The same model explains why many simultaneous connections cost so little here, where one operating system thread per connection would have cost a great deal more.
The model has a flip side: a long calculation blocks the entire server, since nobody else holds the thread. Expensive work is handed to a dedicated worker thread, or to another process.
Frequently asked questions
Is Node.js a language?
No, the language is still JavaScript. Node.js is the environment running it, just as the browser is, with its own library of modules. Confusing the two leads people to hunt in the language for functions that in fact belong to the runtime.
Which version should be installed?
Always one carrying an even major number, known as long-term support: it receives security fixes for roughly three years. Odd-numbered releases exist for experimentation and stop being maintained quickly. A version manager lets several live side by side and switch per project.
Is Node right for everything?
It shines on work that waits a lot and computes little: APIs, file servers, command-line tools, network-driven processing. For intensive continuous computation, other runtimes keep the edge. Our Node.js course starts from that divide to build a complete API.