devnotes.

Node.js Core Modules

Core modules are the toolkit that ships inside Node.js itself — no npm install, no node_modules, no version to track. You just require() them by name and they're ready.

A quick tour of the ones you'll reach for most

const fs = require('fs');       // read/write files and directories
const http = require('http');   // build servers, make HTTP requests
const path = require('path');   // work with file and folder paths safely
const os = require('os');       // information about the machine Node is running on
const crypto = require('crypto'); // hashing, encryption, random values
const events = require('events'); // build custom event-driven objects

A small example touching three of them together

const os = require('os');
const path = require('path');
const fs = require('fs');

const logPath = path.join(os.tmpdir(), 'app.log');

fs.writeFileSync(logPath, `Started on ${os.platform()} at ${new Date().toISOString()}\n`);
console.log('Log written to:', logPath);

Here, os.tmpdir() finds the operating system's temp folder (different on Windows vs. macOS vs. Linux), path.join() combines it with a filename correctly regardless of OS-specific slash characters, and fs.writeFileSync() writes the file. Three core modules, zero external installs.

Why they matter beyond convenience

Core modules are maintained by the Node.js project itself, tested against every new Node release, and battle-tested by essentially every Node.js application in existence. Reaching for a core module first — before installing a third-party package for the same job — usually means fewer dependencies to update, fewer security advisories to track, and one less thing that can break when Node.js itself changes.

How to know what's available

Node.js ships with dozens of core modules covering file systems, networking, cryptography, compression, streams, and more — the official Node.js documentation lists every one with its full API. A rule of thumb worth keeping: before reaching for npm, check whether a core module already does the job.

Node.js Core Modules | DevNotes