Node.js: Basic to Advanced
Learn how Node really works: modules, streams, HTTP, TCP, workers and testing.
- modules
- 13
- topics
- 100
- exercises
- 350
- of practice
- 86 h 50 min
About this course
Learn Node.js from the runtime to advanced topics in very easy English. Build real programs with files, streams, HTTP servers, TCP sockets, worker threads and tests, then finish with projects.
What you'll learn
13 modules and 100 topics. Every topic has short lessons, a quiz, hands-on exercises checked in your browser, and interview questions.
Includes 26 editor tasks: you write the code in your own editor and push it to your practice repo on GitHub, and the task is marked done. How it works
1How Node Runs JavaScript
How Node runs JavaScript: V8, libuv, the event loop and the core modules.
- What Node.js Is
- V8, libuv and the Thread Pool
- The Event Loop's Phases
- nextTick, Microtasks and setImmediate
- Blocking the Event Loop
- Project: Non-blocking Report
- How Node Runs JavaScript — assessment
2Modules: CommonJS and ES Modules
CommonJS and ES modules, and how Node finds and loads files.
- CommonJS Modules: require and module.exports
- ES Modules in Node
- How Node Finds Modules
- CommonJS and ES Modules Together
- Module Caching and Circular Dependencies
- Project: price-utils Package
- Modules: CommonJS and ES Modules — assessment
3npm and package.json
package.json, npm install, scripts, versions and the lockfile.
- package.json, Field by Field
- npm Scripts and node --run
- Semantic Versioning and Ranges
- Lockfiles and npm ci
- Dependency Types and the Dependency Tree
- Command-Line Tools: bin, Shebangs and npx
- Project: Dependency Checker
- npm and package.json — assessment
4Process, Environment and the Command Line
The process object, environment variables, arguments and exit codes.
- The process Object and the os Module
- Command-Line Arguments: process.argv and util.parseArgs
- Environment Variables, .env Files and Config
- stdin, stdout and stderr
- Exit Codes, process.exitCode and process.exit()
- Signals and Graceful Shutdown
- Project: todo CLI
- Process, Environment and the Command Line — assessment
5Files and Paths
Read, write and watch files, and build paths the safe way.
- Building Paths with node:path
- File URLs and import.meta
- Reading and Writing Files
- Folders, stat, Removing and Copying
- File System Errors and Races
- Atomic Writes and a JSON Store
- Project: Photo Organiser
- Files and Paths — assessment
6Events and EventEmitter
EventEmitter: listeners, synchronous emit, error events, leaks, and awaiting events.
- EventEmitter Basics
- emit Is Synchronous
- Error Events
- Extending EventEmitter
- Listener Leaks and Cleanup
- events.once, events.on and EventTarget
- Project: Order Pipeline
- Events and EventEmitter — assessment
7Buffers and Encodings
Bytes, Buffers and text encodings such as UTF-8.
- Bytes, Unicode and UTF-8
- Buffer Basics
- Base64, Base64url and Hex
- Reading Binary Data
- TextEncoder, TextDecoder and Split Characters
- Project: Order Record Codec
- Buffers and Encodings — assessment
8Streams and Backpressure
Read and write big data in small pieces, and handle backpressure.
- Why Streams?
- Readable Streams
- Writable Streams
- Backpressure and highWaterMark
- pipeline: Connecting Streams Safely
- Transform Streams and Object Mode
- Project: Access-Log Analyzer
- Streams and Backpressure — assessment
9HTTP Server from Scratch
Build an HTTP server from scratch with the http module.
- HTTP Messages: What Travels on the Wire
- Your First Server: createServer and the Request Lifecycle
- Routing by Hand: URLs, Methods and Params
- Reading JSON Bodies Safely
- Status Codes and Headers That Mean Something
- Calling Other Servers with fetch
- Project: Bookmarks JSON API
- HTTP Server from Scratch — assessment
10TCP Sockets with net
TCP sockets with the net module: servers, clients and messages.
- TCP Basics: Addresses, Ports and a Stream of Bytes
- net.createServer and net.connect
- Message Framing: Newlines and Length Prefixes
- Socket Lifecycle: end, destroy, Timeouts and Errors
- HTTP by Hand over a TCP Socket
- Project: TCP Chat Server
- TCP Sockets with net — assessment
11Error Handling and Async Patterns
Error handling, error classes and async patterns, plus graceful shutdown.
- Error-First Callbacks: The Node Contract
- util.promisify and util.callbackify
- Error Classes, Codes and Causes
- Uncaught Exceptions and Unhandled Rejections
- Cancellation and Timeouts with AbortSignal
- Limited Concurrency and Retries with Backoff
- Graceful Shutdown of a Server
- Project: Resilient Fetcher
- Error Handling and Async Patterns — assessment
12Worker Threads, Cluster and Child Processes
Worker threads, cluster and child processes for heavy work.
- CPU-Bound vs I/O-Bound Work
- Worker Threads
- Worker Pools
- Child Processes
- The Cluster Module
- Project: Job Runner
- Worker Threads, Cluster and Child Processes — assessment
13Testing and Debugging
The built-in test runner, mocks, and debugging with the inspector.
- The Built-in Test Runner
- Assertions in Depth
- Hooks, Test Doubles and Mocks
- Testing Async Code, Streams and Servers
- Debugging Node.js
- Profiling and Memory Leaks
- Project: Fix the Invoice Module
- Testing and Debugging — assessment