The File System and Paths

Every server in this book touches the disk. Express 24,430 serves static assets from a folder, multer 12,087 drops uploads into a directory, your logger rotates files, and your configuration loader reads .env before anything else starts. All of it goes through one module, node:fs.

The file system is also where the gap between your laptop and your server shows up first. You develop on Windows, where names are case-insensitive; you deploy to Linux, where Users.js and users.js are two different files. The node:path module closes that gap, and using it costs nothing.

node:fs carries Stability 2 in the Node.js 26.9.0 2,131 documentation; the few members marked otherwise are labeled where they appear below. Import it with the node: prefix so readers and bundlers can tell a core module from a package. 10 shows what happens when you call fs.readFile.

How an asynchronous fs call travels from JavaScript to the disk and back
How an asynchronous fs call travels from JavaScript to the disk and back

Two consequences bite in production. Asynchronous file work runs on four threads by default, so 200 concurrent reads queue behind four workers; and a synchronous call skips the pool, blocking the thread that serves every HTTP request your process holds.

Subsections