Node.js Tutorial
Run JavaScript on the server: modules, the event loop, files, streams and a plain HTTP service
Beginner to Intermediate4 lessonsabout 24 min of reading
This course is for people who already know basic JavaScript (variables, functions, arrays, promises at a glance) and want to use it outside the browser. If you have only ever written code that runs on a web page, Node.js will feel familiar and strange at the same time: the language is the same, but there is no page, no window, and your program talks to files, sockets and the operating system instead.
By the end you will be able to organise a project into modules and know why one file can use import while its neighbour needs require, predict the order in which callbacks, promises and timers run, read and write files without loading them whole, and build a small JSON service with nothing but the built-in node:http module. That last lesson is the foundation under frameworks such as Express and Fastify, and it is also what interviewers are probing when they ask how Node handles many requests on one thread.
The four lessons build on each other: the runtime and its two module systems, then the event loop that decides when your code runs, then files, streams and buffers (where the event loop meets real I/O), and finally an HTTP service that uses everything before it. Every snippet was run on Node 22, and the output shown is the real output of that run. If you later want to put an API like this to work, continue with REST API Development.
Node.js lessons
- 1Node.js Runtime and Modules: ESM vs CommonJS ExplainedUnderstand what the Node.js runtime provides, how ES modules and CommonJS differ, and how Node decides which one a file uses, with runnable examples.6 min read
- 2Node.js Event Loop and Async Code: Callbacks, Promises, async/awaitSee how the Node.js event loop orders timers, promises and I/O, why blocking it freezes a server, and how to run async work in parallel safely.7 min read
- 3Node.js File System, Streams and Buffers: Read Big Files SafelyUse the Node.js fs module, Buffers and streams to read, write and transform files of any size without loading them into memory, with working examples.6 min read
- 4Build a Node.js HTTP Server with the Built-in http ModuleBuild a small JSON HTTP API in Node.js using only node:http: routing, body parsing, status codes, errors and graceful shutdown, tested with curl.5 min read
Preparing for an interview? Practise Node.js interview questions
Learning Node.js to land a job? Browse open roles or check which skills are trending.