EMZETT.
Login

Node.js

In short: A JavaScript runtime outside the browser — makes JavaScript a full-fledged language for servers, scripts and build tools.

In more detail: Node.js uses the same V8 JavaScript engine as Chrome, but without a browser environment, and instead with access to the file system, network, etc. Event-driven and non-blocking (an event loop instead of threads per connection), letting it handle many simultaneous connections efficiently. Next.js, npm and practically the entire modern JavaScript tooling landscape run on Node.js.

In Depth

Classic server architectures (e.g. Apache in classic mode) often start their own thread or process per incoming connection — with thousands of simultaneous connections, this creates considerable memory and management overhead. Node.js takes a different approach: a single main thread processes all requests via an event loop, and waiting I/O operations (database query, reading a file, network request) don’t block this thread, but are delegated to the operating system in the background and report back via a callback once they’re done.

const fs = require("fs");
fs.readFile("file.txt", "utf8", (err, data) => {
  console.log(data); // runs asynchronously, doesn't block the main thread
});
console.log("This line runs BEFORE the file content!");

This architecture is excellently suited for I/O-heavy applications (many simultaneous network/database connections with little computation of its own in between), but less suited for computationally intensive tasks (e.g. complex image processing), which would block the single main thread and thereby slow down ALL other requests in the meantime — for that, Node.js offers separate worker threads or offloading to other processes. npm (Node Package Manager) ships directly with Node.js and is, by far, the largest package ecosystem of any programming language.

See also: JS, TypeScript