Node.js
- Pronunciation
- NOHD-jay-ES
In short
Node.js is an open-source JavaScript runtime that runs JavaScript outside the browser, most often to build web servers, APIs, and command-line tools.
What is Node.js?
Node.js is a runtime environment that lets you run JavaScript on a server or on your own computer, not only inside a web browser. It is built on V8, the JavaScript engine from Google Chrome, and was first released by Ryan Dahl in 2009. Node.js is not a programming language or a framework; it is the program that executes your JavaScript and gives it access to files, the network, and the operating system.
Node.js handles work with a single-threaded event loop and non-blocking I/O (input and output, such as reading files or talking to a database). When your code starts a slow operation, Node.js doesn't wait; it moves on to other work and runs a callback, or resumes an async function, when the result is ready. This makes it very efficient at handling many simultaneous connections, such as API requests or WebSocket chats.
Picture a single waiter who takes an order, passes it to the kitchen, and serves other tables while the food cooks, instead of standing at the kitchen door. Node.js ships with npm, the package manager behind the largest registry of open-source JavaScript packages, and it powers frameworks such as Express, Fastify, NestJS, and Next.js as well as most frontend build tools.
Because your JavaScript runs on one main thread, CPU-heavy work such as image processing or large calculations can block every other request until it finishes. Such tasks are usually moved to worker threads, separate processes, or other services. Node.js is also often compared with newer runtimes like Deno and Bun, which run mostly the same JavaScript but differ in built-in tooling and defaults.
At a glance
Key takeaways
- Node.js runs JavaScript outside the browser, on servers and developer machines.
- It is a runtime built on Chrome's V8 engine, not a language or a framework.
- A non-blocking event loop lets one process handle many concurrent connections.
- CPU-heavy work can block the event loop and should be moved elsewhere.
- npm gives access to a huge ecosystem of open-source packages.
Example
// server.mjs: a tiny JSON API with no external packages
import { createServer } from "node:http";
const server = createServer((req, res) => {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ message: "Hello from Node.js" }));
});
server.listen(3000, () => {
console.log("Listening on http://localhost:3000");
});
// Run it with: node server.mjsReaders ask
Is Node.js a programming language?
No. JavaScript is the programming language, and Node.js is a runtime environment that executes it. Node.js adds APIs for files, networking, and processes that browsers don't provide.
Is Node.js frontend or backend?
Node.js runs on servers and developer machines, so it is mainly used for backend code. Frontend developers also rely on it every day to run build tools, bundlers, and local development servers.
Is Node.js single-threaded?
Your JavaScript runs on a single main thread driven by the event loop, but Node.js uses a background thread pool for some I/O tasks. You can also create extra threads with the worker_threads module for CPU-heavy work.
See also
- Node.js vs DenoBoth run JavaScript on V8; Node.js gives scripts full access and has the largest ecosystem, while Deno runs TypeScript directly and asks for permissions.
- Node.js vs BunNode.js is the long-standing JavaScript runtime built on V8; Bun is a faster-starting runtime on JavaScriptCore that also installs, tests and bundles code.
- JavaScriptWeb Development, p. 29JavaScript is the programming language that runs in web browsers to make pages interactive, and it also runs on servers through runtimes like Node.js.
- TypeScriptWeb Development, p. 60TypeScript is a programming language built on JavaScript that adds static types, catching many bugs before the code runs, and compiles to plain JavaScript.
- Async/AwaitProgramming Fundamentals, p. 5Async/await is a syntax for writing asynchronous code that reads like ordinary step-by-step code, pausing at each await until a promise or task finishes.
- CallbackProgramming Fundamentals, p. 8A callback is a function passed as an argument to another function, which then calls it later, for example when a task finishes or an event happens.
- ConcurrencyProgramming Fundamentals, p. 15Concurrency is a program's ability to make progress on several tasks in overlapping time periods, such as serving many users at once rather than one at a time.
- APIBackend & APIs, p. 2An API is a set of rules that lets one piece of software request data or actions from another in a predictable, documented way.
- npmWeb Development, p. 38npm is Node.js's default package manager and the world's largest software registry; it downloads a project's dependencies and tracks their versions.
- ExpressBackend & APIs, p. 19Express is the most widely used Node.js web framework: a minimal layer that handles routing, requests and responses through a chain of middleware functions.
- ES ModulesWeb Development, p. 19ES modules are JavaScript's built-in module system: each file keeps its own scope and shares code with other files through import and export.
- DenoBackend & APIs, p. 13Deno is an open-source JavaScript and TypeScript runtime that keeps system access locked until you grant it and ships its own formatter, linter and test runner.
- BunBackend & APIs, p. 9Bun is a fast JavaScript and TypeScript runtime that is also a package manager, bundler and test runner, designed as a drop-in replacement for Node.js.
Free · once a week
Software and AI, explained once a week
The week's software and AI news with every term explained, plus a term to learn and a quick quiz. A two-minute read.
See this week's issueAbout this page
Page history
Added a diagram: V8, libuv and the event loop.
Changes that altered what this page says. Typo fixes are not listed.
Spotted a mistake or something missing on this page?Suggest an edit
How pages are made