Node.js

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

The reference material consulted while preparing these pages is listed in the section bibliography.

This section is written against Node.js 26 (26.10.0, the Current line, which becomes LTS on 2026-10-28), with the differences of Node.js 24 LTS (Krypton, 24.21.0) and Node.js 22 (Jod, 22.23.3, Maintenance) called out where they matter, and npm 11 as bundled with those lines (npm 12.2.0 is the latest npm but is not bundled with any Node.js line). All versions were checked on 2026-10-03. Node.js releases a new line every year; from Node.js 27 every line becomes LTS, so the baseline is re-verified rather than assumed, and each page says which line introduced, stabilised or removed a feature. Features still marked Experimental in the official stability index are labelled as such and kept short.

What Node.js is

Node.js is an open-source, cross-platform JavaScript runtime. It combines the V8 JavaScript engine with libuv (the asynchronous I/O library), a set of C++ bindings and a JavaScript core library, and it runs your code on a single main thread driven by an event loop, handing blocking work to the operating system, a small thread pool, or worker threads. It is a runtime, not a framework: it gives you files, sockets, HTTP, streams, cryptography, a test runner and an embedded SQLite database, and leaves structure to you or to frameworks such as Express, Fastify or NestJS.

This section is for developers who:

  • know some JavaScript (see the JavaScript Development reference) and want to learn how Node.js actually works, not only how to call frameworks

  • come from Java, Python, .NET or Go and want the mental model of the event loop, modules and npm

  • maintain older Node.js code or follow older tutorials and books, and need to know what changed (CommonJS to ES modules, dotenv to --env-file, Jest to node:test, ts-node to type stripping, Corepack removal)

The Bookshelf scenario

Every example builds Bookshelf, the same domain used by the FastAPI, NestJS and Next.js sections, so the stacks can be compared. It is built mostly from built-ins: a JSON service on node:http storing data in node:sqlite, a bookshelf command-line tool, a streaming CSV import, cover-image hashing in a worker_threads pool, ISBN lookups with fetch, a live "new review" feed over Server-Sent Events, node:test suites, clustering, a single-executable build and a Docker image. Pages that need third-party libraries extend it with Express or Fastify, database clients, BullMQ, Nodemailer, an LLM SDK or ws. Pages build on each other, but each can be read on its own.

Diagram of the Bookshelf components and the deployment around them
Figure 1. The Bookshelf components built across the section

Reading path

The pages are ordered so that each one builds on the previous ones:

  1. Foundations: what Node.js is, installing it, the release lines, running scripts, flags and globals

  2. Modules and packages: CommonJS, ES modules, interop, package.json, npm, workspaces and publishing

  3. Asynchrony: the event loop, promises, timers, events, not blocking the loop, async context and cancellation

  4. Core APIs: process, errors, buffers, util, os/path/url, terminal I/O

  5. Files and streams: the file system, streams, Web Streams, zlib, SQLite and databases

  6. Networking: HTTP servers and clients, TLS and HTTP/2, WebSockets and SSE, TCP/UDP/DNS, hardening

  7. Concurrency: worker threads, child processes, cluster

  8. Testing: the built-in test runner, mocks, snapshots and coverage

  9. Diagnostics: debugging, profiling, memory, reports and observability

  10. Security: best practices, the permission model, cryptography

  11. TypeScript and tooling: type stripping, linting and formatting

  12. Building applications: REST APIs, frameworks, authentication, CLIs, queues, email, LLM APIs

  13. Production: deployment, containers, single executable applications, upgrading

mindmap root((Node.js)) Foundations Architecture Installing Release lines CLI and REPL Globals Modules and packages CommonJS ES modules package.json npm Asynchrony Event loop Promises Timers Events Core APIs Process Errors Buffers util Files streams data fs Streams zlib SQLite Networking HTTP TLS and HTTP2 WebSockets fetch Concurrency Workers Child processes Cluster Quality Testing Debugging Security TypeScript Building and production REST APIs Frameworks Docker SEA Upgrading
Figure 2. Mind-map of the topics covered in this section

What’s covered

Existing pages are linked rather than repeated; the Node.js pages add only what they lack.

Existing page(s) How it relates to this section

Asynchronous JavaScript

Engine-level event loop, micro and macrotasks. This section owns the libuv phases, nextTick and setImmediate.

JavaScript Modules

ES module syntax and a CommonJS overview. This section owns resolution, "type", exports/conditions and require(esm).

Bundling, npm & Publishing

Bundlers, package.json, SemVer, publishing and trusted publishing. This section adds npm ci, lockfiles, workspaces and audit.

Jest, ESLint & Prettier, Babel

Linked from the testing and tooling pages rather than repeated.

Browser Workers

Web Workers, contrasted with worker_threads.

Standard Library Utilities, Exception Handling

Timers, queueMicrotask and uncaught errors. This section owns process events and Node.js error codes.

TypeScript Getting Started, TypeScript Modules, tsconfig & Compiler Options, TypeScript Classes

Type stripping, nodenext and @tsconfig/node*. The Node.js section covers only the runtime side.

NestJS (performance, lifecycle and shutdown, deployment, configuration, debugging, Fastify, uploads, authentication)

The same runtime primitives seen through a framework. This section documents them framework-free.

Next.js

Next.js running on Node.js: runtimes, the Node.js server, standalone output, environment variables.

Docker, Kubernetes

Dockerfiles, cache mounts, probes and termination. The Node.js Docker page shows only what is Node.js-specific.

Messaging, OAuth, Architecture

Kafka and RabbitMQ, OAuth and JWT theory, and patterns; linked from the queues and authentication pages.

SQL, MongoDB drivers, Redis, Pagination Strategies

Engines and drivers. The databases page shows only how to use each from Node.js.

CLI Frameworks for Node.js, MCP Node.js Servers, LangChain.js

CLI frameworks, MCP and LangChain on Node.js; linked from the CLI and LLM pages.

React Server Rendering, CORS, AWS Lambda

SSR on Node.js streams, CORS, and Lambda Node.js runtimes.

Starting a New Project

Backend framework choice, including JavaScript and TypeScript on Node.js.

Bibliography

Every source used to generate this section, each linked to its official website. Individual pages list the subset they derive from under their own == References heading. The two books below were consulted for concept coverage and narrative only; every code example is written against the current official documentation, which wins wherever a book differs, and each page says where a book is outdated.

Books

Official Node.js documentation and resources

Ecosystem projects

Runtimes, tooling and operations