Lesson content
Read, practise, then check your understanding
Node.js runs JavaScript outside the browser with event-driven I/O and built-in modules. It provides process, buffers, streams, filesystem, networking, and worker APIs but no page DOM.
Module choices
// ESM
import { readFile } from "node:fs/promises";
export async function load(path) { return readFile(path, "utf8"); }
// CommonJS legacy shape
// const { readFile } = require("node:fs/promises");
Package type, .mjs/.cjs extensions, and exports fields control interpretation and resolution. Avoid mixing systems casually. Read configuration from validated environment variables, handle signals for graceful shutdown, and never block the event loop with large synchronous operations in request paths.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.