Node.js is an open-source, cross-platform JavaScript runtime built on Google Chrome's V8 engine. It lets developers run JavaScript outside the browser to build fast REST APIs, real-time WebSocket servers, CLI tools, and microservice backends using one language across the stack.
Traditional blocking servers assign a separate operating-system thread to wait on every database query or file read. Node.js uses a single main JavaScript thread paired with a non-blocking event loop (libuv) that offloads network and disk I/O to the kernel and invokes callbacks or promises only when data arrives.
flowchart LR
A["Incoming Requests"] --> B["Node.js Event Loop"]
B -->|"Non-blocking I/O"| C["Database / File System / Network"]
C -->|"Completion Callback"| D["Callback / Microtask Queue"]
D --> B
B --> E["HTTP Responses"]
Because Node.js never pauses waiting on idle I/O sockets, one server process easily serves thousands of concurrent API requests, chat streams, or proxy connections with low memory overhead.
Node.js shines for I/O-heavy workloads such as JSON APIs, Next.js server rendering, real-time dashboards, and developer CLIs. For heavy CPU tasks like video encoding or large matrix math, offload work to Worker Threads or a compiled native service so the event loop stays responsive.
import http from 'node:http';
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ service: 'api', status: 'ok', path: req.url }));
});
server.listen(3000, () => {
console.log('Node.js server listening on http://localhost:3000');
});
fs.readFileSync() or running massive while loops inside an HTTP route freezes every other connected user until the work finishes.window and document do not exist on the server; Node.js exposes process, Buffer, and built-in node: modules instead.try / catch around await calls so failed queries return clean HTTP 500 responses instead of crashing the process.Node.js is a JavaScript runtime environment, not a language or web framework. Frameworks like Express, Fastify, and NestJS run on top of Node.js.
fetch() natively?Yes. Node.js 18+ includes standard global fetch(), Request, and Response APIs without installing third-party HTTP libraries.
node:?The node: prefix (like import fs from 'node:fs/promises') tells Node explicitly to load a built-in module rather than searching node_modules.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.