Node.js Mastery

JavaScript on the server: modules, npm, the event loop, files, streams and HTTP, with real Node APIs you run in every lesson.

39 lessons across 8 units: modules and npm, the event loop, async patterns, files, buffers and streams, HTTP servers and production habits, with 57 runnable examples, quizzes and 40 coding problems that use real Node APIs.

Units
8
Lessons
39
Coding problems
40
Examples
57

Free: units 1 to 2 (9 lessons). Units 3 to 8 with DevArcade Pro.

See pricing

What you'll learn

  • Meet NodeWhat Node is, process and exit codes, configuration from the environment, CommonJS and ES modules.
  • npm and Packagespackage.json and scripts, semantic versioning, dependencies and lockfiles, and how Node finds packages.
  • The Event LoopOne thread and non-blocking I/O, the loop phases, nextTick and microtasks, timers, and CPU-bound work.
  • Async PatternsError-first callbacks, promisify, running promises together, EventEmitter, and cancellation with AbortController.
  • Files and PathsSafe paths, reading and writing, directories and metadata, atomic writes, and a log report.
  • Buffers and StreamsBytes and encodings, readable and writable streams, backpressure, transforms and pipeline.
  • HTTP ServersHTTP as text, createServer, query strings and JSON bodies, routing, and serving static files.
  • Production NodeErrors, middleware, testing with node:test, logging and graceful shutdown, then the notes API boss.

Course outline

8 units and 39 lessons. Each lesson has a short read with examples you run, a quiz, and coding problems tested in your browser; most have a step-through visualizer.

  1. Unit 1:Meet Node

    What Node is, process and exit codes, configuration from the environment, CommonJS and ES modules.

    Free
    1. What Node.js Is JavaScript outside the browser: the V8 engine, libuv and the core modules, and how Node differs from the browser you know.
      1 problem
    2. process: Arguments and Exit Codes Read command line arguments from process.argv, report success or failure with exit codes, and know cwd from __dirname.
      1 problem
    3. Configuration from the Environment process.env, NODE_ENV and .env files, why every value is a string, and validating configuration once at startup.
      1 problem
    4. CommonJS: require and module.exports How require loads a file, the module wrapper, module.exports versus exports, the module cache and circular dependencies.
      1 problem
    5. ES Modules in Node import and export in Node: how a file is picked as ESM or CommonJS (.mjs, .cjs, "type"), the differences, and mixing the two.
      1 problem
  2. Unit 2:npm and Packages

    package.json and scripts, semantic versioning, dependencies and lockfiles, and how Node finds packages.

    Free
    1. package.json and npm Scripts The fields that matter in package.json, running scripts with npm run, pre and post hooks, and passing arguments through.
      1 problem
    2. Semantic Versioning and Ranges MAJOR.MINOR.PATCH, what ^ and ~ allow (and the 0.x special case), and how npm matches a version against a range.
      1 problem
    3. Dependencies, Lockfiles and npx dependencies versus devDependencies and peerDependencies, why package-lock.json is committed, npm ci, npx, and supply-chain hygiene.
      1 problem
    4. How Node Finds Packages The node_modules lookup that require('name') performs, package entry points with main and exports, and why packages get deduplicated.
      2 problems
  3. Unit 3:The Event Loop

    One thread and non-blocking I/O, the loop phases, nextTick and microtasks, timers, and CPU-bound work.

    Pro
    1. One Thread, Non-blocking I/O Why one JavaScript thread can serve thousands of connections, what the libuv thread pool does, and how blocking code stalls everyone.
      1 problem
    2. The Phases of the Event Loop Timers, poll, check and close: what runs in each phase, and why setImmediate beats setTimeout inside an I/O callback.
      1 problem
    3. process.nextTick and Promise Callbacks The two queues that run between every callback, why nextTick goes first in CommonJS, and batching work at the end of the current tick.
      1 problem
    4. Timers, Promises and Timeouts Node's Timeout objects (unref, refresh), timers/promises, AbortSignal.timeout, and putting a deadline on any promise.
      1 problem
    5. CPU-bound Work and Worker Threads When work needs more than one core: worker_threads for CPU-heavy JavaScript, child processes, running several instances, and splitting the work.
      1 problem
  4. Unit 4:Async Patterns

    Error-first callbacks, promisify, running promises together, EventEmitter, and cancellation with AbortController.

    Pro
    1. Error-first Callbacks Node's original async convention: (err, result) callbacks, the rules every callback API follows, and running several at once.
      1 problem
    2. From Callbacks to Promises util.promisify and the promise APIs of fs and timers, wrapping a callback API yourself, and keeping `this` intact.
      1 problem
    3. Running Promises Together Sequential versus parallel awaits, Promise.all, allSettled, race and any, and capping how many tasks run at once.
      1 problem
    4. EventEmitter Node's publish and subscribe building block: on, once, off and emit, the special 'error' event, listener order, and leaks.
      1 problem
    5. Cancellation with AbortController AbortController and AbortSignal across fetch, timers and fs, AbortSignal.timeout and any, and retrying with backoff that can be cancelled.
      1 problem
  5. Unit 5:Files and Paths

    Safe paths, reading and writing, directories and metadata, atomic writes, and a log report.

    Pro
    1. Paths Done Right join, resolve, dirname, basename, extname, parse and relative, and keeping user-supplied paths inside a folder.
      1 problem
    2. Reading and Writing Files readFile, writeFile and appendFile with fs/promises, encodings and Buffers, JSON files, and handling ENOENT and friends by error code.
      1 problem
    3. Directories and Metadata mkdir with recursive, readdir with file types, stat for size and times, removing trees, and walking a folder recursively.
      1 problem
    4. Safe Writes and File Flags Open flags (w, a, wx), why a crash mid-write corrupts files, and the write-to-temp-then-rename pattern that prevents it.
      1 problem
    5. Project: A Log Report Put the unit together: read an access log, parse each line, skip malformed ones, and aggregate counts, error rates and the slowest request.
      1 problem
  6. Unit 6:Buffers and Streams

    Bytes and encodings, readable and writable streams, backpressure, transforms and pipeline.

    Pro
    1. Buffers and Encodings Bytes versus characters, UTF-8, hex and base64, Buffer.from, concat and byteLength, and slices that share memory.
      1 problem
    2. Readable Streams Why streams exist, chunks and highWaterMark, data and end events, async iteration, and keeping state across chunk boundaries.
      1 problem
    3. Writable Streams and Backpressure write() and end(), what write() returning false means, waiting for 'drain', and why ignoring it fills memory.
      1 problem
    4. Transforms and pipeline() Transform streams, object mode, and stream.pipeline: connecting stages with backpressure, error handling and cleanup, including async generators.
      1 problem
    5. Project: Convert a File, Streaming Read a CSV file, turn every row into a JSON line, and write it out, all streaming with constant memory through one pipeline.
      1 problem
  7. Unit 7:HTTP Servers

    HTTP as text, createServer, query strings and JSON bodies, routing, and serving static files.

    Pro
    1. HTTP in Plain Text What a request and a response look like on the wire: the request line, headers, the blank line and the body; methods and status codes.
      1 problem
    2. Your First HTTP Server http.createServer, the req and res objects, status codes and headers, listening on a port, and calling your server with fetch.
      1 problem
    3. Query Strings and JSON Bodies Parsing req.url with URL, reading the request body stream, size limits, content types, and answering bad input with 400, 413 and 415.
      1 problem
    4. Routing with Parameters Route tables instead of if-chains, matching /notes/:id patterns, method handling with 404 versus 405, and the shape of every framework router.
      1 problem
    5. Serving Static Files Content types by extension, streaming files to the response, path traversal, and caching with ETag and 304 Not Modified.
      1 problem
  8. Unit 8:Production Node

    Errors, middleware, testing with node:test, logging and graceful shutdown, then the notes API boss.

    Pro
    1. Errors in Production Operational versus programmer errors, error classes that carry an HTTP status, one central error handler, and what to do with uncaught exceptions.
      1 problem
    2. Middleware and Composition The middleware idea behind Express and Koa: a chain of functions that each do one job and call next(), and the onion model of async middleware.
      1 problem
    3. Testing with node:test Node's built-in test runner and assert module, testing async code and HTTP handlers, mocks, and what makes a test catch bugs.
      1 problem
    4. Logging and Graceful Shutdown Structured JSON logs with levels and child loggers, logging to stdout, request ids, and shutting down on SIGTERM without dropping requests.
      1 problem
    5. Boss: A Notes API Everything at once: a JSON REST API over node:http with routing, validation, proper status codes and a JSON file that survives restarts.
      1 problem

Start Node.js Mastery for free

Enroll for free and units 1 and 2 are yours. DevArcade Pro opens every unit of every course, including new ones as they launch, monthly or yearly.

All courses