Node.js guides
Every published Node.js guide, newest first, with practical examples you can copy into your own project.
3,815 guides across 14 topics
Topics
Popular Node.js guides
Most readLatest Node.js guides
Page 1 of 1Node.js EventEmitter: once, error Events, and Listener Memory Leaks
emit is synchronous, so a throwing listener aborts the rest. An error event with no listener crashes the process, and a listener per request is the classic leak.
Node.js crypto: Hashing, HMAC, AES-GCM, and Random Bytes
Hashing, HMAC, AES-256-GCM and randomness solve different problems. Never reuse a GCM nonce, never hash a password with sha256, and compare secrets with timingSafeEqual.
Node.js HTTP Server, Headers, AbortSignal, and Native fetch
Nothing is parsed for you: an unread body stalls the socket, and headers cannot change after the first write. fetch resolves on 404, and AbortSignal is the timeout mechanism.
Node.js worker_threads: SharedArrayBuffer and CPU Offloading
Each worker has its own isolate, event loop, and module cache. postMessage copies unless you transfer, and Atomics.wait on the main thread blocks the whole server.
Node.js child_process: spawn, exec, fork, and IPC Channels
spawn streams and never uses a shell; exec buffers through /bin/sh and is the injection surface. fork adds an IPC channel, and killing a tree needs a process group.
Node.js Buffer and TypedArray: Encodings and Binary Manipulation
A Buffer is a view over an ArrayBuffer, so byteLength is not string length and toString can silently corrupt split UTF-8. allocUnsafe and pooled buffers carry old data.
Node.js Streams: Readable, Writable, Transform, and pipeline
pipe() forwards data but not errors; pipeline() destroys the chain and rejects. Backpressure is the false return from write(), and _flush that never calls back hangs forever.
Node.js fs/promises: Read, Write, Watch, and Atomic File Operations
writeFile truncates before writing, so a crash leaves half a file. The atomic pattern is temp file, fsync, rename; readFile loads everything, so large files need streams.
Node.js ESM vs CommonJS: import, require, and package.json exports
"type" decides how a .js file loads, and the exports field decides what a package exposes. Missing extensions, __dirname, and dual-package state are the usual failures.
Node.js Event Loop: Phases, Microtasks, and nextTick Order
Six phases, two queues that are not phases, and one rule: nextTick then microtasks drain between every callback. Why setTimeout and setImmediate swap order at top level.