Node.js Cheat Sheet

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

A single-page, colour-coded summary of the Node.js essentials, written against Node.js 26 (26.10.0, Current; it becomes LTS on 2026-10-28), with the differences of Node.js 24 LTS (24.21.0) and Node.js 22 (22.23.3, Maintenance) called out, and npm 11 as bundled with those lines (versions verified 2026-10-03) — what the runtime is made of, the CLI and REPL, CommonJS and ES modules, npm, the event loop, promises and events, process and error handling, files and streams, built-in SQLite, HTTP and networking, concurrency, the test runner, diagnostics, security, TypeScript type stripping, production, and a strip of what changed since older tutorials — handy for quick memorization or as a downloadable PDF desk reference.

Download the Node.js Cheat Sheet (PDF)

For the full explanation, every option, and additional examples, see the dedicated pages:

Start here — Node.js and its Bibliography.

Concurrency & scaling — Concurrency Models, Worker Threads, Child Processes, and Cluster & Scaling.

TypeScript & tooling — TypeScript in Node.js, and Linting, Formatting & Tooling.

Beyond the basics — Native Add-ons, WebAssembly & FFI.

Worked example

One small ES module that exercises four of the essentials above: concurrent promises, error codes from a failed file read, a stream pipeline and a one-shot event listener. Save it as cheat.mjs and run it with node cheat.mjs.

cheat.mjs
import { EventEmitter } from 'node:events';
import { readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
import { pipeline } from 'node:stream/promises';
import { Readable, Transform } from 'node:stream';

// Promises: two 100 ms waits run concurrently with Promise.all
const started = performance.now();
const results = await Promise.all([sleep(100, 'a'), sleep(100, 'b')]);
const elapsed = performance.now() - started;
console.log('results:', results, 'concurrent:', elapsed < 190);

// Errors: a failed read rejects with a code
try {
  await readFile(new URL('./missing.txt', import.meta.url));
} catch (err) {
  console.log('caught:', err.code);
}

// Streams: pipeline handles backpressure and cleanup
const upper = new Transform({
  transform(chunk, _enc, cb) { cb(null, chunk.toString().toUpperCase()); },
});
let out = '';
await pipeline(
  Readable.from(['node', ' ', 'streams']),
  upper,
  async function (source) { for await (const c of source) out += c; },
);

// Events: a one-shot listener
const bus = new EventEmitter();
bus.once('done', (text) => console.log('event done:', text));
bus.emit('done', out);
console.log('listeners left:', bus.listenerCount('done'));

Output on Node.js 24 (the program uses only APIs that exist on 22 and 26 as well):

results: [ 'a', 'b' ] concurrent: true
caught: ENOENT
event done: NODE STREAMS
listeners left: 0

The two 100 ms waits finish together because Promise.all() starts both before awaiting either, the missing file surfaces as a rejection carrying err.code, pipeline() closes every stream in the chain when it ends, and once() removes its listener after the first call.