Node.js Introduction
Node.js lets you run JavaScript outside the browser β on servers, the command line, and build tools. It's why JavaScript can power a full backend.
How Node works
Node runs on Chrome's V8 engine and uses a non-blocking, event-driven model. A single main thread handles many connections by never waiting idly β it kicks off slow work (file reads, network calls) and processes the results as they arrive via the event loop.
What it's great for
| Use case | Why Node fits |
|---|---|
| REST/GraphQL APIs | handles many concurrent requests efficiently |
| Real-time apps | chat, live updates (WebSockets) |
| CLI tools | fast to build, huge ecosystem |
| Build tooling | bundlers, linters, dev servers |
The single-threaded model
Because I/O is non-blocking, one thread serves thousands of connections β ideal for I/O-heavy work. CPU-heavy work (image processing, big calculations) can block that thread, so it's offloaded to worker threads (a later chapter).
The npm ecosystem
Node comes with npm, the world's largest package registry. Almost any capability you need is an npm install away.