bhylu.com

Advertisements

Node.js Built-in Modules Reference

A useful module reference starts with the resource and lifetime involved. File handles, HTTP sessions, event listeners and cryptographic keys need different handling even when their APIs return familiar objects.

Your brief

Use fs/path for owned files, stream for transfers, events for local notifications, http/https for request/response lifecycles, net/tls/dgram for lower-level transport, and crypto for explicitly selected primitives. Cluster workers are processes; worker_threads workers are isolates in one process. util adapters do not repair every callback API contract. The actual lessons exercise those APIs; this compact index only checks that the reviewed runtime exposes their built-in module names.

Run the code

Run this example locally with Node.js. The exact sources are reviewed on Node 22.15.1 and Node 24.22.1 unless a specialised lab states otherwise. Save the complete source as reference-guide.mjs in a separate empty exercises folder and run node reference-guide.mjs. There is no Node.js browser runner on Bhylu; the plain JavaScript playground does not provide these filesystem, server or process APIs.

Download the complete source. Ordinary Node scripts need no Apache, PHP or MySQL service. File examples own their temporary folders; network fixtures use loopback and available temporary ports.

Worked solution

Show the worked solution
reference-guide.mjs

import { builtinModules } from 'node:module';
const needed = [
  'fs',
  'path',
  'events',
  'stream',
  'buffer',
  'http',
  'https',
  'net',
  'tls',
  'dgram',
  'crypto',
  'util',
  'readline',
  'worker_threads',
  'cluster',
  'zlib',
  'perf_hooks',
  'vm',
];
console.log(
  needed.every(
    (name) => builtinModules.includes(name) || builtinModules.includes('node:' + name),
  ),
);
console.log(needed.length);

Expected result

true
18

Availability is not the same as executing every method or testing every protocol mode. Follow the linked worked lessons for actual resource creation, expected results, failures and cleanup. Their environment notes identify where an optional package or external tool is needed.

Extend and test

Choose three modules and describe the resource each creates, how a caller observes failure and which scope closes or releases it.

Use the Node.js API reference for the precise version contract.