Node.js
A runtime that lets you run JavaScript outside the browser, on servers. Built on Chrome's V8 engine. Lets you use one language (JavaScript/TypeScript) for both frontend and backend. Non-blocking I/O via the event loop makes it great for APIs and real-time apps.
- Backend APIs (REST, GraphQL).
- Real-time apps (chat, WebSockets).
- Full-stack JS/TS projects.
- CLI tools and build scripts.
- CPU-intensive compute (use Go/Rust/Python+native).
- Systems programming.
Definition
Node.js is a JavaScript runtime built on V8, with a non-blocking event loop and libuv for async I/O. npm is the package manager. You build servers, CLIs, and tools. Frameworks: Express (minimal), Fastify (fast), Next.js (full-stack). Single-threaded but async.
Why it exists
To let developers use JavaScript on the server, enabling full-stack JS and sharing code/types between frontend and backend. The event loop handles many concurrent connections efficiently without thread-per-connection.
How it works
V8 executes JS; libuv provides the event loop and async I/O (file, network). Non-blocking calls use callbacks/promises/async-await. One thread runs JS; worker threads and child processes add parallelism. npm installs packages from the registry.
Scaling limits
Single-threaded for JS (CPU work blocks the event loop). Use worker threads or child processes for CPU-heavy tasks. Callback/promise chains can get complex (async/await helps). npm dependency trees can be huge.
Cost shape
Free and open source.
Alternatives
- Deno — Same V8 but secure-by-default, TS built-in, smaller ecosystem.
- Bun — Faster runtime, less mature.
Failure modes
- Blocking the event loop.
- npm dependency hell.
- Callback hell (use async/await).