Node.js — Runtime Internals, Express, APIs and SQL Server
What it is & where it is used
Node.js is a JavaScript runtime that runs JavaScript outside the browser — on servers, build tools and CLIs. It uses Google's V8 engine to execute JavaScript and libuv to provide non-blocking I/O through an event loop, so one process can handle thousands of concurrent connections with a single main thread.
| Used for | Examples |
|---|---|
| Web APIs and backends | Express, Fastify, NestJS, Koa |
| Full stack frameworks | Next.js, Nuxt, Remix, SvelteKit |
| Real-time apps | Chat, live dashboards with Socket.IO/WebSockets |
| Tooling | npm, Vite, webpack, Angular CLI, ESLint, TypeScript compiler |
| Serverless | AWS Lambda, Azure Functions, Vercel Functions |
Node.js vs ASP.NET Core: both are fast, cross-platform backends. Node shares one language (JavaScript/TypeScript) with the frontend and has the largest package ecosystem (npm); .NET offers strong typing by default, multithreaded CPU performance and a richer built-in framework.
Versions & history
| Version | Year | Highlights |
|---|---|---|
| 0.1 | 2009 | Ryan Dahl creates Node.js (V8 + event loop) |
| 0.x / io.js | 2010–2015 | npm (2010), Express (2010); io.js fork merges back → Node.js Foundation (2015) |
| 4–8 | 2015–2017 | ES2015+ support, LTS releases begin, async/await (v7.6/8) |
| 10–12 | 2018–2019 | Worker threads, HTTP/2, N-API stable |
| 14–16 | 2020–2021 | ES modules stable, optional chaining, Apple Silicon support |
| 18 | 2022 | Global fetch, built-in test runner (node:test), watch mode later |
| 20 | 2023 | Permission model (experimental), stable test runner, single executable apps |
| 22 | 2024 (LTS) | require() of ES modules, WebSocket client, --experimental-strip-types (run TypeScript) |
| 24 | 2025 (LTS from Oct 2025) | npm 11, V8 13.x, URLPattern global, TypeScript type stripping on by default |
| 25 | 2025 (Current) | Next "current" line; even versions become LTS each October |
Release model: a new major every April and October; even-numbered releases become LTS (30 months of support). Use an Active/Maintenance LTS version in production.
Lifecycle
How Node.js handles a request:
node server.jsstarts the process: V8 is initialised, your module is loaded and executed top to bottom (synchronous setup), then the event loop starts.http.createServer(...).listen(3000)registers a listening socket with the OS via libuv.- A request arrives → the OS notifies libuv (epoll/kqueue/IOCP) → the event loop runs your request callback on the main thread.
- Your handler calls
await db.query(...)→ the query is sent on a socket (non-blocking) and the handler yields; the main thread serves other requests. - When the DB answers, the promise resolves; its continuation is queued as a microtask and runs on the main thread.
- File-system operations, DNS lookups, crypto and zlib run on libuv's thread pool (4 threads by default) and report back to the loop.
- The response is written; when there is nothing left to do (no timers, sockets or pending work), the process exits.
Event loop phases (libuv):
┌───────────────────────────┐
┌─>│ timers │ setTimeout / setInterval callbacks whose time has come
│ ├───────────────────────────┤
│ │ pending callbacks │ some deferred system callbacks (e.g. TCP errors)
│ ├───────────────────────────┤
│ │ idle, prepare │ internal
│ ├───────────────────────────┤
│ │ poll │ retrieve new I/O events; run I/O callbacks; may block here waiting
│ ├───────────────────────────┤
│ │ check │ setImmediate callbacks
│ ├───────────────────────────┤
└──┤ close callbacks │ socket.on('close') etc.
└───────────────────────────┘
Between every callback: process.nextTick queue, then the Promise microtask queue are drained.Tools used to develop
- Runtime & package managers: Node.js (nvm / nvm-windows / fnm to switch versions), npm, pnpm, yarn; npx.
- Frameworks: Express, Fastify, NestJS (Angular-like structure, DI), Koa, Hono.
- Data:
mssql(SQL Server via tedious), Prisma ORM, Sequelize, TypeORM, Knex,pg,mysql2, Mongoose. - Dev tools: nodemon /
node --watch, ts-node / tsx, ESLint, Prettier, Chrome DevTools (node --inspect), VS Code debugger. - Testing:
node:test, Jest, Vitest, Supertest (HTTP), Playwright. - Production: PM2, Docker,
clinic.js(performance), OpenTelemetry, pino/winston (logging).