What Node.js is
Node.js is an environment that runs JavaScript outside the browser: on your computer or on a server. The language is the same one you learned in the tutorial, but instead of a page and buttons the program gets access to files, the network and the operating system. Node.js is used to write web servers, command-line utilities and build tools.
Version
The course targets Node.js 22 and newer. Even-numbered versions (22, 24) get LTS status — long-term support: they receive fixes for several years, so they are the ones installed on servers. All examples use ES modules (import and export) and built-in modules with the node: prefix.
Installing
Download the installer from nodejs.org — pick the version marked LTS. Then open a terminal and check the result:
node --version
npm --versionThe first command prints the Node.js version, for example v22.12.0, the second the version of npm, the package manager that comes with Node.js.
How Node.js differs from the browser
| In the browser | In Node.js |
|---|---|
document and window exist | They do not: there is no page |
| No access to files | Files can be read and written |
| Code comes from a website | Code lives on your computer |
| Network limited by browser rules | Any request can be sent and received |
The language itself — variables, functions, classes, promises — works the same way.
What we will build
One example runs through the whole course — a small blog. First you will learn to keep posts in a JSON file, then you will write an HTTP server that returns them as a list and one by one, and accepts new posts and comments. Everything uses built-in modules, no frameworks. Once you see how a server works by hand, it becomes clear what Express and other frameworks do for you.
Course outline
| Chapter | About |
|---|---|
| Getting started | Running programs, package.json, modules, npm |
| Program and environment | Arguments, environment variables, paths |
| Files | Reading, writing, folders, streams |
| Asynchrony | The event loop, events, errors |
| HTTP without frameworks | A server, routes, a JSON API, fetch |
| Tools and practice | Tests, debugging, a database, deployment |
Common mistake
Code written for the browser does not work in Node.js: there are no page objects here.
// document.querySelector('h1');
// ReferenceError: document is not defined
console.log(typeof document); // undefinedIf you see document is not defined, a script meant for a web page was run with node. Such code is attached to an HTML page, not executed in the terminal.