Hands-on, runnable examples for the core Node.js concepts. Each file is self-contained, heavily commented, and ends with a TRY THIS section so you learn by changing the code, not just reading it.
From inside this folder, use either the direct command or the npm script:
| Concept | Direct command | npm script |
|---|---|---|
| 1. Event loop | node 01-event-loop.js |
npm run event-loop |
| 2. async / await | node 02-async-await.js |
npm run async |
| 3. Modules (ESM) | node 03-modules/main.js |
npm run modules |
| 3b. Modules (CommonJS) | node 03-modules/legacy.cjs |
— |
| 4. Filesystem | node 04-filesystem.js |
npm run files |
| 5. HTTP server (raw) | node 05-mini-server.js |
npm run server |
| 6. Express (framework) | node 06-express-server.js |
npm run express |
| 7. EventEmitter | node 07-eventemitter.js |
npm run events |
| 8. Streams | node 08-streams.js |
npm run streams |
The npm scripts live in
package.jsonunder"scripts"— that's the standard place projects define their commands. Runnpm runwith no args to list them all.
- Event loop — the foundation. Predict the output before running.
- async / await — the everyday tool, built on the event loop.
- Modules — how real projects split code across files.
- Filesystem — async/await applied to real I/O.
- HTTP server — everything together; a working web server.
The project's manifest: its name, version, the module system
("type": "module" = use modern import/export), runnable scripts,
and (once you install any) its dependencies. npm install <pkg> adds a
package to node_modules/ and records it here.