# Core Node.js modules: fs, path, http, events

*JavaScript Developer Study Guide · Server Side JavaScript · Last updated October 16, 2026 · https://www.certifyforce.com/study-guide/javascript-developer/server-side-javascript/core-nodejs-modules-fs-path-http-events*

The built-in modules the exam expects you to reach for: fs in its sync, callback and promise forms, path.join versus path.resolve and __dirname, http.createServer, EventEmitter ordering and the 'error' event, child_process, crypto hashing and util.promisify, and when a framework such as Express is worth a dependency.

- Certification: Salesforce JavaScript Developer
- Exam section: Server Side JavaScript
- Study guide: https://www.certifyforce.com/study-guide/javascript-developer

**Official exam objective:**

> Know the core Node.js modules and given requirements, infer which Node.js library/framework is a good solution.

## What the exam expects

- Choose the fs form (synchronous, callback, `fs/promises`) that fits a requirement, and spot the bug when the callback API is awaited.
- Predict `path.join()` and `path.resolve()` output, and build file paths that do not depend on the working directory.
- Build a dependency-free HTTP server with `http.createServer()` and know when a framework such as Express earns its place.
- Predict the order of `EventEmitter` listener calls, including `once()` and the `'error'` event.
- Pick the module for a job: `child_process` to run a command, `crypto` to hash, `util.promisify` to adapt a callback API.

Key terms: **core module** (ships with Node.js, loaded with the `node:` prefix, no npm install); **error-first callback** (a callback whose first argument is reserved for an error); **`__dirname`** (directory of the current CommonJS module); **EventEmitter** (object that calls registered listeners when a named event is emitted); **framework** (a third-party package such as Express that adds routing and middleware on top of `http`).

## Key facts

| Fact | Detail | Source |
|---|---|---|
| fs forms | Every operation has synchronous, callback and promise-based forms | [File system](https://nodejs.org/api/fs.html) |
| Callback convention | First callback argument is reserved for an exception | [File system](https://nodejs.org/api/fs.html) |
| `path.resolve()` | Right to left until absolute; falls back to the working directory | [Path](https://nodejs.org/api/path.html) |
| `__dirname` | Directory name of the current module | [Modules: CommonJS modules](https://nodejs.org/api/modules.html) |
| `import.meta.dirname` | ESM equivalent for `file:` modules; no longer experimental since v24.0.0 and v22.16.0 | [Modules: ECMAScript modules](https://nodejs.org/api/esm.html) |
| `http.createServer()` | Returns an `http.Server`; the listener is added to `'request'` | [HTTP](https://nodejs.org/api/http.html) |
| Listener order | Synchronous, in registration order | [Events](https://nodejs.org/api/events.html) |
| Listener warning | Printed above 10 listeners for one event; nothing removed | [Events](https://nodejs.org/api/events.html) |
| Unhandled `'error'` | Thrown; stack trace printed; process exits unless the exception is caught | [Events](https://nodejs.org/api/events.html) |
| `exec` vs `execFile` | `exec` spawns a shell; `execFile` runs the executable directly by default | [Child process](https://nodejs.org/api/child_process.html) |

## Check yourself

- Why does `await fs.readFile(file, 'utf8')` throw when `fs` is `require('node:fs')`?
- When does `path.resolve()` use the current working directory?
- Why should every long-lived `EventEmitter` have an `'error'` listener?
- Which two `child_process` functions return a command's stdout to a callback?

## Sources

- [File system](https://nodejs.org/api/fs.html)
- [Path](https://nodejs.org/api/path.html)
- [Events](https://nodejs.org/api/events.html)
- [HTTP](https://nodejs.org/api/http.html)
- [Node.js Documentation index](https://nodejs.org/api/)
- [Modules: CommonJS modules](https://nodejs.org/api/modules.html)
- [Modules: ECMAScript modules](https://nodejs.org/api/esm.html)
- [Process](https://nodejs.org/api/process.html)
- [Child process](https://nodejs.org/api/child_process.html)
- [Util](https://nodejs.org/api/util.html)
- [Crypto](https://nodejs.org/api/crypto.html)
- [Worker threads](https://nodejs.org/api/worker_threads.html)
- [Net](https://nodejs.org/api/net.html)
- [HTTPS](https://nodejs.org/api/https.html)
- [Express/Node introduction (MDN)](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Introduction)

## About the full unit

The "Core concepts", "Exam traps" and "Worked scenario" sections of this unit, its 7 linked practice questions, and unlimited timed mock exams are included with the JavaScript Developer pack (USD $19): https://www.certifyforce.com/practice-exams
