Technology
The Brilliance of Node.js
Node.js, introduced by Ryan Dahl in 2009, took JavaScript from the browser to the server with an event loop, non-blocking input and output and the npm registry. This essay explains how it works, why it displaced the old-style website of threads and full page reloads, and why it remains the foundation beneath modern frameworks, tooling and services.

Contents ▾
Node.js is the runtime that took JavaScript, a language written in 1995 for small scripts inside web pages, and made it a practical way to build the servers those pages come from. It did so not by adding power in the abstract but by removing a specific inefficiency. The servers of the 1990s and 2000s gave each connection its own thread and then left that thread waiting, often for most of its life, on a disk, a database or another server. Ryan Dahl, who introduced Node at JSConf EU in Berlin in November 2009, built the opposite arrangement around Google’s V8 engine — a single event loop, operations that do not block it, and callbacks that run when the waiting is over.
That one decision explains most of what followed. Because a Node process does not spend its time waiting, it can hold thousands of open connections on modest hardware, which suited the web that was arriving in 2009 — pages that updated themselves, chat and collaboration in the browser, and later the application programming interfaces behind mobile applications. Because the language on the server was the language already in the browser, code, data in JavaScript Object Notation and whole teams could move across a boundary that had previously required two languages and a translation layer. And because Dahl’s runtime arrived with npm, a package manager that made other people’s code installable in one command, its facility grew by accumulation — frameworks, test runners, build tools and the servers themselves all written in the same language and distributed through the same registry.
This essay follows that story in full, from JavaScript before Node to the governance and long-term support that now carry it, and it sets Node against the old-style website at each stage rather than in passing. The comparison is not that the older web was badly built. It is that its arrangements — a thread per request, a page rebuilt in full for every action, polling for news that a server could have sent — fitted a web of documents, and fitted a web of applications poorly. Node’s brilliance, such as it is, is practical rather than rhetorical. It is the facility of a small, well-placed idea, kept stable for more than fifteen years, on which a very large amount of subsequent development has been able to rest.
1. What Node.js actually is
Node.js is a runtime environment for JavaScript.[1] A runtime environment is the software that takes code written in a programming language and executes it, providing the facilities that code needs while it runs, such as access to memory, files, timers and the network. JavaScript is the programming language itself. Node.js is not the language, and it is not a framework, which is a pre-written structure that a developer builds an application inside. It sits underneath both. A developer writes JavaScript, optionally using a framework, and Node.js is the program that runs that code on a computer.
That distinction matters because for the first fourteen years of its life JavaScript ran almost exclusively inside a web browser. The browser supplied the runtime. It decided what JavaScript could touch, and for security reasons it deliberately prevented JavaScript from reading files on a visitor’s disk, opening network connections to arbitrary machines, or listening for incoming connections from other computers. Node.js removed that confinement by supplying a different runtime, one designed for a server. A server, in this context, is a program that waits for requests from other programs, does work in response, and sends back a reply. Once JavaScript had a runtime that could open files, talk to databases and accept incoming network connections, the same language that animated a page in a browser could also run the machine behind the page.
The official description published at nodejs.org states the design in one sentence. Node.js is described there as an open-source, cross-platform JavaScript runtime environment that runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser. Each part of that sentence carries weight. Open-source means the source code is publicly available and may be inspected, modified and redistributed under its licence, in Node’s case the MIT licence for most of the project. Cross-platform means the same runtime is built for Microsoft Windows, macOS and Linux, and for processor architectures including x64 and ARM, so code written on a laptop in one operating system can be deployed unchanged onto a Linux server. Outside a web browser is the break with everything JavaScript had been before 2009.
The three parts underneath
A working Node.js installation rests on three layers. At the bottom is V8, the JavaScript engine built by Google for its Chrome browser and released as open source in 2008. An engine is the component that parses JavaScript text, compiles it to instructions the processor can execute, and manages memory while it runs. Chapter four examines V8 in detail. Node.js does not interpret JavaScript slowly line by line and leave it at that. It hands the code to V8, which compiles much of it to native machine code during execution.
The second layer is libuv, a library originally written for Node.js that provides asynchronous input and output across operating systems. Input and output, usually shortened to I/O, covers any operation that moves data in or out of a program, such as reading a file, querying a database or receiving data over a network socket. A socket is one endpoint of a network connection, identified by an address and a port. Windows, macOS and Linux each handle I/O and networking through different system interfaces, and libuv presents a single consistent interface above them. It also supplies the event loop and a pool of background threads for operations that cannot be completed asynchronously by the operating system itself, such as some file system work. The event loop is the mechanism that schedules work in Node.js, and it is the subject of chapter five.
The third layer is Node’s own code, written largely in C++ and JavaScript. It binds V8 and libuv together and adds a standard library of built-in modules. A module is a self-contained unit of code that a program loads only when it needs it. The built-in modules include http for creating web servers and making web requests, fs for working with the file system, path for handling file paths correctly on different operating systems, stream for processing data in chunks rather than loading it whole into memory, crypto for hashing and encryption, os for information about the host machine, and events for the event emitter pattern on which much Node code is built. These modules ship with the runtime. A developer who installs Node.js already has, without adding anything, enough to write a functioning web server in a few lines of code.
A small program that shows the whole idea
The example Node.js itself has used in its documentation for many years creates a web server using only the built-in http module. The program loads that module, calls its method for creating a server, tells the server how to respond to a request, and instructs it to listen on a port, conventionally port 3000 during development or port 8080 in examples. When a browser or another program connects, the server responds with a short plain-text or HTML reply. There is no separate web server program to install and configure first, no application server to deploy into, and no second language for the server side. The JavaScript file is the server. Running the command node followed by the file name starts it, and it stays running, waiting for connections, until it is stopped.
That command gives the project its working shape. node is a single executable program. A developer downloads an installer or a binary archive from nodejs.org, installs it, and gains both the runtime and, alongside it, npm. The letters npm originally stood for Node Package Manager. It is the command-line tool and the public registry for reusable JavaScript packages, and its scale is the subject of chapter six. For now it is enough to note that the runtime and the package tool have been distributed together from an early stage, so the facility a developer receives is not a bare language interpreter but a runtime, a standard library and an established route to hundreds of thousands of published components.
Single process, event-driven design
Node.js runs a developer’s JavaScript in a single main thread by default. A thread is a sequence of execution that a processor carries out, and many traditional server designs allocated one thread to each incoming connection. Node.js took a different approach, described in its own documentation as an asynchronous event-driven JavaScript runtime designed to build scalable network applications. Asynchronous means that when the program starts an operation that will take time, such as reading from a database, it does not sit idle waiting for that operation to finish. It registers what should happen when the result arrives, and moves on to other work. Event-driven means the program’s flow is governed by events, occurrences such as a connection arriving, a timer expiring, or a file finishing loading.
This is a description of the model, not a claim that Node.js can use only one processor core or that it never uses threads. libuv maintains its own thread pool for certain operations, newer versions of Node provide a worker_threads module for running JavaScript itself in parallel threads when a task genuinely requires it, and a production deployment commonly runs several Node processes on one machine, often coordinated by a process manager or by the clustering support in the built-in cluster module, so that every core is used. The point of the design is where the default lies. In Node.js the default is to handle many waiting connections cheaply in one process, because most web work consists largely of waiting, for databases, for other services, for data to arrive over the network, rather than of continuous calculation.
What people actually build with it
The range of uses that followed from that design is wider than the web server in the introductory example. Node.js became a common choice for application programming interfaces, usually shortened to APIs. An API is a defined set of addresses and message formats through which one program requests work or data from another. A mobile application, a browser application and a third-party service can all call the same Node API and receive data, commonly formatted as JSON. JSON, short for JavaScript Object Notation, is a text format for structured data based on JavaScript’s own syntax for objects and lists, and it became the default data format of the modern web in the same period that Node spread.
Node.js also became the substrate under much of the tooling that front-end developers use every day, whether or not their finished product runs Node in production. Build tools that bundle JavaScript files together, transpilers that convert newer JavaScript syntax into forms older browsers understand, test runners, linters that check code for errors and style problems, and development servers that reload a page when a file changes are routinely written in JavaScript and executed by Node. A developer building a website that will never itself be served by Node may still spend the whole working day running Node programs. That second career, as the engine room of the development process itself, is a large part of the facility the title of this essay refers to, and chapter twelve returns to it.
Beyond the browser and the traditional server, the same runtime has been used for command-line tools distributed through npm, for scripts that automate file processing and deployment, for services that aggregate data from other services, and for the server-side rendering of web pages, in which a server generates the initial HTML for a page so that it arrives readable rather than as an empty shell waiting for JavaScript to fill it. None of these uses required a new language to be invented. They required JavaScript to be given a general-purpose runtime, which is precisely the gap Node filled.
Versions, releases and long-term support
Node.js is maintained as a continuing series of releases rather than as a finished product. New major versions appear on a regular cycle, and even-numbered major versions are promoted to long-term support, shortened to LTS. An LTS release is one that the project commits to maintaining with bug fixes and security updates for an extended period, typically thirty months in total under the schedule the project has followed in recent years, which makes it the line that production users are advised to run. Odd-numbered versions become the testing ground for newer features and are supported for a shorter period. The Node 20, Node 22 and Node 24 lines represent this pattern in the mid-2020s, with Node 22 and Node 24 holding LTS status in succession as the schedule advanced. The project publishes its release timetable openly, and end-of-life dates for each line are known in advance, so an organisation can plan an upgrade rather than discover one.
Governance changed as the project grew. Node began in 2009 as the work of one programmer, Ryan Dahl, sponsored by the company Joyent. It later passed through a fork and reunification, covered in chapter three, and in 2015 came under the Node.js Foundation. In 2019 that foundation merged with the JS Foundation to form the OpenJS Foundation, which now hosts the project. Development takes place in public, in a repository on GitHub, with contributions from individuals and from engineers employed by companies that depend on the runtime. The practical consequence for a user is continuity. The runtime is not tied to the commercial survival of a single vendor, and its direction is set by a technical steering committee drawn from its contributors.
What Node.js is not
Precision about what Node.js is requires equal precision about what it is not. It is not a programming language, so it did not change JavaScript’s syntax or add new language features of its own. Improvements to the language itself come through ECMAScript, the standard to which JavaScript conforms, and reach Node when the version of V8 it embeds implements them. It is not a web framework, so it does not by itself prescribe how an application should organise its routes, its data or its files. Frameworks such as Express, which chapter ten covers, supply that structure on top of it. It is not a database, a hosting service or a browser, although it can connect to the first, run on the second and generate pages for the third.
Nor is it the right tool for every workload, a point its own documentation has never concealed. A task that consists of heavy continuous calculation on one thread, such as encoding video or running a large numerical simulation in JavaScript, will occupy that thread and delay everything else the process is handling, because the event loop cannot process other events while a long calculation runs. Node’s answers to that problem, worker threads, child processes and handing the calculation to a specialised service or a native add-on written in a language such as C++, are real but they are workarounds around a known boundary rather than a denial of it. The workloads Node was designed for, and on which its reputation rests, are those dominated by connections and I/O. Understanding that boundary is part of understanding the design, and it is why the history that follows begins not with Node itself but with the language and the web as they stood before it appeared.
2. JavaScript before Node
JavaScript was created in 1995 at Netscape Communications, the company whose Navigator browser then held most of the web browser market. Netscape had hired a programmer named Brendan Eich in April 1995, originally to work on adding the Scheme programming language to the browser. The plan changed. Netscape wanted a language that looked approachable to the far larger number of developers familiar with Java, the language Sun Microsystems was promoting heavily that year, and that could be written directly inside a web page to make it respond to a reader. Eich produced the first version in ten days in May 1995. That compressed timetable, repeated by Eich himself in later accounts, explains a number of the language’s enduring quirks. It was first called Mocha, then renamed LiveScript, and then, in a joint announcement with Sun on 4 December 1995, renamed JavaScript, a marketing decision that tied its name to Java while the two languages remained technically distinct.
The distinction is worth holding on to because the similar names still cause confusion three decades later. Java is a compiled language in which code is converted in advance into bytecode and run on a virtual machine, a program that simulates a computer for the code it executes. JavaScript, as built in 1995, was an interpreted scripting language embedded in a browser, intended for comparatively small tasks inside a page. They share some surface syntax, such as curly braces around blocks of code, and almost nothing else. A Java programmer in 1996 could not simply read a JavaScript program and run it, and a web author writing JavaScript had no access to Java’s libraries.
Standardisation and the browser wars
Netscape submitted JavaScript to Ecma International, a standards organisation based in Geneva, in November 1996, seeking a standard that other companies could implement. The result, published in June 1997 as ECMA-262, was named ECMAScript, because the name JavaScript was a Netscape and Sun trademark matter rather than a neutral standards label. ECMAScript is the standard, JavaScript is the best-known implementation of it, and the two terms are often used interchangeably in practice. A second edition followed in 1998 and a third in December 1999. ECMAScript 3 became the stable baseline that browsers implemented for most of the following decade, and a great deal of the JavaScript still described in tutorials of the 2000s is ECMAScript 3 JavaScript.
Standardisation did not produce uniformity at the speed its authors hoped, because the late 1990s were the period of the browser wars, the commercial contest between Netscape Navigator and Microsoft’s Internet Explorer for control of how people reached the web. Microsoft reverse-engineered JavaScript and shipped its own version, JScript, in Internet Explorer 3 in August 1996. The two browsers also diverged sharply in the Document Object Model, shortened to DOM. The DOM is the representation of a web page that a program can manipulate, in which the page’s elements, such as headings, paragraphs, images and form fields, are organised as a tree of objects that code can read and change. Because Netscape and Microsoft built different DOMs, a script that moved an element or responded to a mouse movement in one browser often failed in the other. Developers of the period wrote code twice, detected which browser was in use, and maintained separate branches for each.
The World Wide Web Consortium, the web’s main standards body, published its DOM Level 1 specification in October 1998 in an attempt to give both camps a common target, and browsers converged gradually over the following years. The practical experience of writing JavaScript in the late 1990s and early 2000s, however, was of inconsistency, limited debugging tools and a reputation for fragility. JavaScript was widely used for small effects, image rollovers that changed a picture when a pointer passed over it, form validation that checked a field before a form was submitted, and pop-up windows. It was rarely trusted with the main work of an application, which remained on the server in languages such as Perl, PHP, Java or Microsoft’s ASP.
The sandbox and what it forbade
The reason for that division of labour was not only reputation. It was architecture. JavaScript in a browser ran inside a sandbox, a restricted environment designed on the assumption that the code was untrusted, because it arrived from a website the visitor had chosen to open and might not have reason to trust. The sandbox enforced the same-origin policy, a rule that a script from one site may not read data from another site’s pages, and it denied access to the visitor’s file system, to the operating system, and to network connections other than back to the site the page came from. Those restrictions were, and remain, correct for a browser. Without them, any advertisement embedded in a page could read a visitor’s documents.
The consequence was that JavaScript, however widely deployed, was not a general-purpose programming environment. By the mid-2000s it was almost certainly the most widely distributed language in the world by reach, since every browser contained an implementation and every interactive website used some of it, yet it could not open a file, run a server, connect to a database, or carry out any of the ordinary tasks expected of a language used to build the back end of a system. The back end is the part of an application that runs on servers, stores data and enforces rules, as distinct from the front end, the part a user sees and touches in a browser or an app. JavaScript owned a large share of the front end and none of the back end. Developers therefore worked in at least two languages as a matter of routine, one for the browser and another, with a different syntax, different libraries and a different community, for the server.
Ajax and the growing ambition of the browser
That settlement began to look temporary in 2004 and 2005, when a set of techniques grouped under a new name changed what a web page could do.[2] Google launched Gmail in April 2004 and Google Maps in February 2005, and both behaved in ways that ordinary web pages did not. Gmail updated the inbox without reloading the whole page. Google Maps let a user drag a map and fetched new map tiles in the background as the view moved. The underlying technique relied on a browser object called XMLHttpRequest, first introduced by Microsoft in Internet Explorer 5 in 1999 as part of Outlook Web Access, which allowed a script to send a request to a server and receive a response without a full page load.
On 18 February 2005 the designer Jesse James Garrett of Adaptive Path published an essay giving the technique a name, Ajax, an abbreviation for Asynchronous JavaScript and XML. Garrett’s essay did not invent the method. It named a pattern that several large applications were already using, and the name spread quickly through the development community. Ajax changed the centre of gravity of web development. Pages became applications that fetched data and updated parts of themselves continuously, which meant far more JavaScript, doing far more consequential work, than the rollovers and form checks of the 1990s. It also increased the load on servers in a specific way that matters for the chapters that follow. An Ajax application holds many more, smaller interactions with a server than a traditional site that delivers one complete page at a time, and it often keeps those interactions running while a user stays on a single page.
Libraries, and learning to live with inconsistency
Developers responded to the browser inconsistencies of the Ajax era by building libraries that hid them. The most influential was jQuery, released by John Resig in August 2006. jQuery provided a single, shorter syntax for selecting elements in the DOM, attaching responses to events, animating parts of a page and making Ajax requests, and it handled the differences between browsers internally. A developer wrote jQuery once and it worked in Internet Explorer, Firefox, Safari and Opera without separate branches. Other libraries of the period, including Prototype, MooTools and Dojo, pursued similar aims with different designs. jQuery won a dominant share of use and for years was present on a large majority of the most visited websites.
jQuery’s success is instructive for understanding the world Node entered. It showed that a very large population of developers wanted to write JavaScript and would adopt a tool that removed friction, even when the underlying platform was uneven. It also showed the limits of working inside the browser. jQuery made client-side code more productive, but it did not give JavaScript a file system, a server or a package system, and it did not resolve the language’s performance limits in the implementations of the day. Before V8, most browser JavaScript engines executed code considerably more slowly than a compiled language, which reinforced the assumption that serious computation belonged elsewhere.
Earlier attempts to take JavaScript to the server
Node was not the first attempt to run JavaScript outside the browser, and the earlier attempts clarify why it succeeded where they did not. Netscape itself offered server-side JavaScript as early as 1996 in its LiveWire product, which ran JavaScript on a Netscape enterprise server. It found little adoption and was discontinued as Netscape declined. Mozilla’s Rhino, begun at Netscape in 1997 and later maintained by the Mozilla Foundation, implemented JavaScript in Java and allowed it to be embedded in Java applications, where it was used for scripting rather than as the main language of a server. Aptana’s Jaxer, released in 2008, placed a browser-like environment, including a DOM, on the server. Projects such as Helma, written in Java and using Rhino, built web applications in JavaScript through the 2000s for a smaller community of users.
Each of these efforts had a working implementation. What they lacked was a combination that arrived only at the end of the decade. They had no fast modern engine comparable to V8, which Google released in September 2008. They had no large, central package registry to make reusable code easy to find and install. They arrived either before Ajax had created a large population of developers fluent in JavaScript, or without a clear answer to the problem of handling many simultaneous connections, which was the specific technical argument Ryan Dahl made for Node in 2009. By 2008, therefore, the ingredients existed separately. JavaScript had a standard, a large developer population, a newly demanding role in the browser, and, with V8, an engine that treated its speed as a serious engineering problem. What it did not yet have was a runtime built around that engine for general-purpose use. That was the work of the following year.
3. Ryan Dahl and the invention in 2009
Ryan Dahl is an American software engineer who, in the mid-2000s, was working on web development using the Ruby programming language and its Rails framework, including work connected with the file-hosting service Flickr in accounts he later gave of the period. The problem that drew his attention was ordinary and visible to anyone who uploaded a large file at the time. A browser uploading a file to a server could not easily show how much of the upload had arrived, because the server software typically accepted the whole transfer, processed it, and only then responded. Showing a live progress bar required the server to answer questions about an upload while that upload was still in progress, which meant handling several things at once for the same user and for many users simultaneously.
Dahl’s criticism, set out in the talk that introduced Node and repeated in interviews afterwards, was directed at the way the dominant web servers of the period handled concurrency. Concurrency is the ability of a system to make progress on more than one task during the same period, for example serving hundreds of visitors at once rather than finishing one visitor’s request before starting the next. The Apache HTTP Server, then the most widely used web server software in the world, in its common configuration assigned each connection to a thread or a process. A process is a running instance of a program with its own allocated memory. When a connection was waiting, for a database query to return or for a slow client to send more data, its thread waited with it, still holding the memory assigned to it. Under that model, the cost of a connection was incurred whether or not the connection was doing any work at that moment, and a server could run out of memory long before it ran out of processing power.
Dahl argued that this was the wrong shape for the web that Ajax had produced. Most connections, most of the time, are waiting. A server that pays a full thread for each waiting connection is spending its resources on idleness. His alternative was to build a server around events and non-blocking operations, so that a single process could keep track of thousands of connections and do work only when there was work to do. Non-blocking means that a call which starts an operation returns at once rather than holding the program until the operation completes. Dahl was not the first engineer to describe this approach. The difficulty of handling ten thousand simultaneous connections had been named as the C10k problem by the engineer Dan Kegel in a widely read essay first published in 1999 and updated through the following decade, and event-driven servers such as nginx, released by Igor Sysoev in 2004, already used similar principles in C. Dahl’s contribution was to build that model into a platform for JavaScript developers, with the language’s own event-based habits as the interface.
Why JavaScript suited the design
The choice of JavaScript was deliberate and, in Dahl’s own explanation, partly a matter of what the language did not have. JavaScript in the browser had no standard library for input and output, because the sandbox described in chapter two forbade it. That absence, which looked like a limitation, meant there was no established blocking way of reading a file or querying a database that Node would have to compete with or break. In languages with mature standard libraries, functions for I/O were usually blocking, and adding non-blocking alternatives alongside them produced a divided ecosystem in which libraries made incompatible assumptions. JavaScript started from a blank page. Node could define its I/O as non-blocking from the first release, and every library written for Node would be written to that assumption.
JavaScript also already trained its developers in the pattern Node required. Browser code is written as responses to events. A developer writes a function to be run when a button is clicked, when a timer fires, or when data arrives from an Ajax request, rather than writing a single sequence of instructions from start to finish. The function supplied to be run later in this way is called a callback. A population of millions of web developers therefore already understood, from daily practice, the style of programming that an event-driven server demands, even if they had never written server software. Dahl’s design asked them to apply a familiar habit in a new place, rather than to learn a new language and a new model at the same time.
Timing added a third reason. Google had released the Chrome browser on 2 September 2008 with V8, an engine that executed JavaScript far faster than the implementations developers were used to, and V8 was open source, written in C++, and designed to be embedded in other programs. Dahl evaluated other possibilities in the course of the work, but V8 gave him a modern, fast, embeddable engine maintained by a large engineering organisation. Without it, a JavaScript server platform in 2009 would have rested on an engine too slow to make the argument convincing.
Building Node at Joyent
Dahl began work on the project in early 2009 and was sponsored in it by Joyent, a company based in San Francisco that sold cloud computing services and had an interest in the software its customers would run. Sponsorship mattered in a practical sense. It allowed Dahl to work on the runtime full time, and it placed Node inside a company that operated servers at scale and could test the ideas against real hosting conditions. The first release of Node.js was made on 27 May 2009. The early versions ran on Linux and macOS. Support for Microsoft Windows arrived later, with version 0.6 in 2011, after work undertaken with Microsoft’s involvement, a step that widened the potential developer base considerably because a large share of developers worked on Windows machines even when their production servers ran Linux.
The project’s name and its small green hexagon logo came later than the code, and the early community was correspondingly small. Node was discussed in 2009 and 2010 in the terms Dahl had used for it, as an evented I/O framework for V8 JavaScript. That phrase, which appeared in the project’s early descriptions of itself, is precise about the priorities. Evented I/O came first. The ambition was not initially to be a general platform for every kind of program, but to do network and file operations in this particular way, and to do them well.
The Berlin talk of November 2009
The public introduction that fixed Node’s reputation took place on 8 November 2009 at JSConf EU in Berlin, the European edition of a conference series devoted to JavaScript.[3] Dahl’s talk, titled in the conference programme as his introduction to Node.js, walked through the reasoning described above, demonstrated a simple web server and a chat-like example handling multiple connections, and showed performance comparisons against established server software for certain workloads. A recording of the talk circulated widely online in the months that followed, and for many developers it was their first encounter with the idea that JavaScript could be a serious server technology.
The talk’s importance lies less in any single benchmark than in the clarity of the problem it named. Dahl presented the cost of a waiting connection as the central inefficiency of contemporary web serving, presented the event loop as the answer, and showed working code rather than a proposal. Developers who watched it could download the software and test the claim themselves the same day. In an industry where new platforms are frequently announced long before they can be used, that immediacy helped Node gather an early community of users who were also, in effect, its testers and its first library authors.
npm and the second founder effect
A runtime alone does not make a platform usable for large applications, because modern software is assembled from reusable parts. Node acquired its package system early, and from a single author. Isaac Z. Schlueter, a developer at Joyent, created npm and released its first version in January 2010. npm gave Node developers a registry from which to download packages, a command-line tool to install them, and a convention, the package.json file, in which a project declares its name, its version and the packages it depends on. A dependency is a package that another package or application requires in order to work. Schlueter’s design decisions, in particular allowing each project to install its own copies of its dependencies rather than forcing one shared copy for the whole machine, made projects portable and reproducible at the cost of duplication on disk. Chapter six examines the consequences of those decisions at length.
Schlueter’s role in the project grew beyond npm. In January 2012 Dahl announced that he was stepping aside from day-to-day leadership of Node, writing that after three years of work on the project he would move to a research role and that Schlueter would take over as the lead maintainer. Dahl later left Joyent, worked at Google on machine learning infrastructure, and in 2018 returned to public attention in this field with a talk listing ten things he regretted about Node, which led to his next project, Deno, covered in chapter fifteen. The 2012 handover is worth recording because it established early that Node was not dependent on its inventor remaining in charge, a test many single-author projects fail.
Early releases and early adopters
Development through 2010 and 2011 proceeded in the version pattern Node used before its later release discipline, with odd and even minor numbers signalling unstable and stable lines. Version 0.4, released in February 2011, was treated by the community as a stable line suitable for wider use. Companies began to report production deployments in that period, and their reports, rather than the project’s own claims, built confidence. LinkedIn’s mobile server work, described publicly by its engineering team in 2011, became one of the most cited early cases, because LinkedIn had rebuilt a service in Node and described in its own account both the reduction in the number of servers required and the development speed of a team working in one language across the client and the server. Chapter eleven treats those production accounts in detail and attributes their figures to the companies that reported them.
Growth also produced strain. By 2014 a substantial group of contributors had become dissatisfied with Joyent’s governance of the project and with the pace of releases, and in December 2014 a fork named io.js was created from Node’s codebase. A fork is a copy of a project’s source code taken in a new direction by a separate group. The io.js group released its version 1.0 in January 2015, incorporating a newer version of V8 than Node then shipped. The split was resolved rather than permanent. In 2015 the Node.js Foundation was established as a neutral home for the project under the Linux Foundation, a technical charter was agreed that gave contributors a formal role in decisions, and in September 2015 Node version 4.0 was released as the convergence of the Node and io.js lines, reuniting the code and the community. The foundation later merged into the OpenJS Foundation in 2019. That sequence, a fork followed by a negotiated reunification under independent governance, is the reason the runtime described in chapter one is now stewarded by a foundation rather than owned by the company that sponsored its creation, and it is a substantial part of why large organisations were willing to build on it for the long term.

4. V8 and the engine room
Every JavaScript program that Node.js runs is executed by V8, and much of what people describe as Node’s speed is in fact V8’s work. V8 is the JavaScript engine developed by Google, written primarily in C++, and released as open-source software under the BSD licence.[4] It was built for the Chrome browser, which Google launched on 2 September 2008, and it was developed by a team based largely in Aarhus, Denmark, led by the Danish programmer Lars Bak. Bak had previously worked on virtual machines for other languages, including the Strongtalk system for Smalltalk and, at Sun Microsystems, the HotSpot virtual machine for Java. That background matters because V8 applied to JavaScript a body of techniques that had been developed over two decades for making dynamically typed languages run fast on virtual machines, at a moment when most browser vendors still treated JavaScript performance as a secondary concern.
A dynamically typed language is one in which a variable is not declared in advance to hold only one kind of value, such as a number or a piece of text. The same variable may hold a number at one point in a program and a string at another, and an object may gain or lose properties as the program runs. This flexibility is convenient for the programmer and difficult for the machine, because code that adds two values cannot assume they are numbers until it checks. An engine for such a language must continually discover what kinds of values a program is actually using and then act on that knowledge without being wrong when the pattern changes. V8’s design is a set of answers to that problem.
Compilation while the program runs
The central technique is just-in-time compilation, usually shortened to JIT compilation. It means translating code into native machine code, the instructions a specific processor executes directly, during the running of the program rather than in a separate step beforehand. Early JavaScript engines were principally interpreters. An interpreter reads source code and carries out its instructions one by one, which starts quickly but repeats the work of understanding the code every time a section runs. A JIT compiler invests effort once in converting a frequently used section of code into machine code, after which that section runs at a speed approaching that of a language compiled in advance. V8 was unusual in 2008 for compiling JavaScript to machine code from the outset rather than relying mainly on interpretation, and the performance gap it opened was large enough that competing browser vendors rebuilt their own engines in response, a period sometimes called the browser engine performance race of the late 2000s and early 2010s.
Modern V8 does not use a single compiler. It uses a pipeline, a sequence of stages through which code passes, with the stages trading speed of compilation against quality of the resulting machine code. Since the release of V8 version 5.9 in 2017, which shipped in Chrome 59, the pipeline has consisted principally of Ignition, an interpreter that produces and executes bytecode, a compact intermediate representation of the program, and TurboFan, an optimising compiler that converts frequently executed bytecode into highly optimised machine code. Code begins under Ignition, which starts it quickly and gathers information about how it behaves. Sections that run repeatedly, described in engine terminology as becoming hot, are handed to TurboFan for optimisation. TurboFan replaced an earlier optimising compiler named Crankshaft, which had been introduced in 2010 and which could not optimise certain language features, including the error-handling construct known as try-catch in its original design. The Ignition and TurboFan combination removed that division, so that the whole language could in principle be optimised by the same route.
Hidden classes and inline caching
Two of V8’s best-documented techniques explain how it handles JavaScript’s flexible objects. The first is hidden classes. Although JavaScript lets a programmer add properties to an object in any order, most programs in practice create many objects with the same properties in the same order, for example thousands of records each with a name, a price and a quantity. V8 internally assigns such objects a hidden class, an internal description of the object’s shape, meaning which properties it has and in what order they were added. Objects that share a shape share a hidden class, and when a property is added V8 records a transition to a new hidden class. With the shape known, V8 can store a property at a fixed offset within the object and find it by arithmetic, instead of searching a general dictionary of names each time the property is read.
The second technique is inline caching. When code reads a property, as in asking for the price of a record, V8 records at that exact place in the code what shape the object had and where the property was found. The next time the same line of code runs, V8 first checks whether the object has the same shape as before. If it does, it uses the remembered location directly and skips the search. If the code at that place is repeatedly given objects of one shape, it stays fast. If it is given several shapes, the cache records several possibilities, and if it is given many different shapes the cache gives up and falls back to a general lookup. Engine documentation describes these states as monomorphic, polymorphic and megamorphic, for one shape, a few shapes and many shapes respectively. The practical advice that follows from this design, and that experienced Node developers apply without necessarily knowing its origin, is that programs run faster when objects of the same kind are built in the same way every time, and when a variable is not made to hold unrelated kinds of value in turn.
Optimisation, speculation and deoptimisation
TurboFan’s optimisations are speculative. It uses the information gathered while the code ran under Ignition, such as the observation that a particular function has so far always received whole numbers, and generates machine code that assumes that pattern will continue. It may thereby omit checks that a more cautious compiler would keep, and produce code that adds numbers using a single processor instruction. Speculation carries a risk, and V8 handles it with deoptimisation. The optimised code contains checks on its own assumptions. If a function that had always received whole numbers is suddenly given a string, the check fails, the optimised machine code is discarded for that execution, and control returns to the bytecode under Ignition, which handles the general case correctly. The program still produces the right answer. It simply runs more slowly until, if the new pattern persists, the code is optimised again on the basis of better information.
This cycle of observation, speculation and retreat is the reason JavaScript performance in Node can be sensitive to patterns that would not matter in a statically typed language, and also the reason it can be surprisingly good. A server program that handles the same kinds of request, with the same shapes of data, thousands of times a second is close to the ideal case for a speculative compiler. Its hot paths are exercised constantly, its object shapes settle, and its caches stay in the fast state. A program that continually presents new shapes and mixed types gives the engine little stable ground to optimise on. The engine is therefore not a fixed quantity of speed underneath Node. It is a system that rewards regularity, and server workloads tend to supply it.
Memory and garbage collection
V8 also manages memory on the programmer’s behalf through garbage collection, the automatic reclamation of memory occupied by objects that a program can no longer reach and therefore can no longer use. Without it, a programmer would have to track and release every allocation manually, and errors in that bookkeeping are a long-standing source of crashes and security faults in languages that require it. V8 divides its heap, the region of memory in which JavaScript objects are allocated, into generations. New objects are allocated in a young generation, which is collected frequently and cheaply on the reasoning that most objects are used briefly and then discarded. Objects that survive repeated collections are promoted to an old generation, which is collected less often by a more thorough process.
The collector for the old generation in modern V8 is called Orinoco, a project developed over several years and completed in its main form by around 2019, whose aim was to move as much collection work as possible off the main thread and to break the remaining work into small increments interleaved with the program’s own execution. The reason for that effort is directly relevant to a server. A garbage collector that stops the program entirely for a long pause delays every request the process is handling at that moment. Short, incremental and partly parallel collection keeps those pauses small, which keeps response times consistent. Node exposes controls over this system, including flags to set the maximum size of the old generation, because a long-running server process with a large working set of data has different requirements from a browser tab. The defaults have risen over the years as machines have gained memory, but a developer running many Node processes on one host still has reason to set the limit deliberately rather than accept it.
What Node adds around the engine
V8 on its own is not a runtime for building servers. It executes JavaScript and manages its memory, but it does not provide a file system, a network stack or timers, and it has no event loop of its own suitable for general use. Embedding is the term for incorporating an engine into a larger program, and V8 was designed to be embedded, with an application programming interface through which a host program can create isolated contexts, load code, expose its own functions to JavaScript, and convert values between C++ and JavaScript. An isolate in V8 terminology is an independent instance of the engine with its own heap, and a context is a separate global environment within an isolate. Node is, in large part, such a host program. It creates the isolate, supplies the event loop through libuv, and exposes operating system facilities to JavaScript as the built-in modules described in chapter one.
That division of labour has a lasting practical consequence. Because Node embeds a version of V8 rather than writing its own engine, improvements made by Google’s team for Chrome arrive in Node when Node updates its embedded V8, which it does in most major releases. Each such update can bring a newer version of the JavaScript language, since new language features are implemented in the engine, as well as performance work and security fixes. It also creates a coupling that Node’s maintainers must manage. A change in V8’s internal interfaces can break native add-ons, which are modules compiled from C or C++ that a JavaScript program loads to do work the language cannot do efficiently itself. Node addressed that problem with a stable application binary interface, a promise about which internal interfaces will not change within a major version, and with a C-based interface layer for add-on authors designed to survive V8 changes between versions. The stability of that boundary is one of the less visible reasons that a large ecosystem of native modules, from database drivers to image processors, could be maintained across many Node releases without being rewritten for each one.
It is therefore accurate, and not a figure of speech, to call V8 the engine room of Node. Dahl supplied the design argument and the I/O model, libuv supplies the cross-platform machinery underneath, and npm supplied the means of distribution, but the reason a language written in ten days in 1995 could be proposed in 2009 as the basis of fast server software was that an engine built in Aarhus for a browser had spent the intervening year demonstrating that JavaScript could be compiled, cached, speculatively optimised and garbage-collected at a standard comparable to far older languages. The next chapter turns to the other half of the design, the event loop that decides when all of that machinery is put to work.
5. The event loop and non-blocking input and output
A Node.js process executes JavaScript on a single main thread.[6] That sentence is often quoted without the qualifications that make it accurate. The process contains other threads, managed largely out of sight, and it can start further processes. What is single is the thread on which a developer’s JavaScript callbacks run by default. Understanding why that arrangement works, and where it stops working, requires following a request through the system rather than repeating the slogan that Node.js is “single-threaded and non-blocking”.
Input and output, shortened to I/O, means any operation that reaches beyond the immediate calculation — reading a file, querying a database, resolving a domain name, accepting a network connection, writing a response. Those operations are slow in a particular way. A processor can perform billions of simple operations in a second. A disc access, a network round trip to another continent, or a database query on a busy machine takes orders of magnitude longer, and most of that time is waiting. The waiting machine has received a request, sent work elsewhere, and has nothing useful to do with that particular request until an answer returns.
A blocking design makes the executing thread wait in place. It issues the file read or the database call and does not move on until the result arrives. A non-blocking design registers an interest in the result and moves on. The thread returns to other work. When the result is ready, a function supplied by the developer, called a callback, is invoked with the data or with an error. Between those two moments the thread has not been idle unless there was genuinely nothing else for it to do.
Ryan Dahl set this choice at the centre of his presentation at JSConf EU in Berlin in November 2009. He argued that web servers spent most of their time waiting on I/O and that the prevailing server models organised that waiting badly. JavaScript, as used in browsers, already had no general facility for blocking file or network access in page code, and browser programming already proceeded by registering handlers for events — a click, a timer expiring, a network response arriving. Node.js carried that event-driven habit to the server and built the runtime around it.
What the event loop does
The event loop is the mechanism that decides what runs next on the main thread. At any moment the thread is either executing JavaScript — a function and the functions it calls, forming a call stack — or it is passing control to the loop to collect the next piece of work. A developer does not call the loop directly. It becomes visible through ordering. Code that registers an asynchronous operation runs to completion first. The callback belonging to that operation cannot interrupt it halfway through, however quickly the underlying work finishes. Only when the current stack empties does the loop deliver queued work.
That rule gives Node.js programs a useful guarantee. Within a single synchronous stretch of code, no other JavaScript callback will interleave and change shared variables unexpectedly. Two callbacks cannot run at the same instant on the main thread, so a large class of race conditions found in multithreaded programs, where two threads alter the same data simultaneously and require locks to stay consistent, does not arise in ordinary Node.js code. The guarantee has a corresponding cost. A callback that performs heavy calculation holds the thread, and while it holds the thread no other callback, timer or incoming request is processed. The loop is not stalled by waiting on I/O. It is stalled by JavaScript itself doing too much at once.
Underneath the loop sits libuv, the cross-platform library written originally for Node.js and maintained as a separate project.[5] libuv presents a uniform interface over facilities that differ between operating systems — epoll on Linux, kqueue on macOS and other BSD-derived systems, and input/output completion ports on Windows. Those facilities share a principle. The operating system can be told which sockets and file descriptors a process cares about, and it will report which of them are ready for reading or writing, instead of the process testing each one in turn. libuv also supplies the thread pool and the abstractions for timers, signals, child processes and file operations that the loop coordinates.
The loop proceeds in phases, and the official Node.js documentation describes them in a fixed order. Each phase has a queue of callbacks associated with it. The timers phase executes callbacks scheduled by setTimeout and setInterval whose threshold has passed. A timer specifies a minimum delay, not a guaranteed time, because earlier phases and a busy stack can postpone it. The pending callbacks phase executes I/O callbacks deferred from a previous iteration, including some system-level errors. An idle and prepare phase is used internally. The poll phase is where the loop calculates how long to wait for new I/O events, retrieves them, and executes their callbacks. If the poll queue empties and no timers are due, the loop may wait in poll for incoming connections and data, unless a check-phase callback has been scheduled to run sooner. The check phase executes callbacks scheduled by setImmediate, which was designed to run immediately after poll completes. The close callbacks phase handles closing handles, for example a socket emitting its close event. The loop then repeats for as long as the process still has active handles and requests keeping it alive, which is why a Node.js server does not simply exit after its first file of code has run — the listening socket is continuing work.
Microtasks and the order of small things
Two further queues sit inside that cycle and explain results that otherwise look arbitrary. After each callback, and after the main script, Node.js empties its microtask queues before moving on. One queue holds callbacks scheduled with process.nextTick. Another holds callbacks attached to promises, the objects described in chapter 13 that represent a future result. The nextTick queue is processed before the promise queue, and both are processed before the loop advances to its next phase. A promise continuation therefore runs sooner than a timer set for zero milliseconds, and a nextTick callback runs sooner than either.
Those priorities are not decorative. A library that defers work with nextTick in a recursive chain can starve the loop indefinitely, because each callback schedules another that must run before the loop reaches poll and handles incoming I/O at all. The official documentation warns against exactly that pattern and points developers to setImmediate for deferring work without blocking I/O indefinitely. Ordering rules of this kind are the price of a system in which many asynchronous operations complete in an order the developer does not directly control. The behaviour is deterministic once the rules are known, and the rules are documented, but they have to be learnt. Callback code that appears to work in a small test can behave differently under load when queues fill and phases take longer.
Where the thread pool enters
Not every operation can be handled by asking the operating system to report readiness. File system operations and several other tasks are handled by libuv through a pool of worker threads. By default that pool contains four threads. DNS lookups performed through the functions that use the system resolver, file reads and writes, directory operations, and certain cryptographic and compression operations in the standard library are among the work sent there. When an operation of that kind is started from JavaScript, libuv assigns it to a pool thread if one is free, or queues it until one becomes free. The pool thread may block on the underlying system call without blocking the main thread. On completion, the result is queued for delivery as a callback through the loop.
The size of the pool can be raised through the UV_THREADPOOL_SIZE environment variable, to a documented maximum of 1,024 threads, but the variable must be set before the pool is first used, and raising it is a remedy for a specific condition — many concurrent file, DNS or cryptographic operations queueing behind four threads — rather than a general performance setting. Network I/O for sockets does not use the pool in the ordinary case. It is handled by the operating system readiness facilities described above, which is why a Node.js process can keep very large numbers of open connections without needing a pool thread for each one. Conflating those two paths is a common error. The connection count is governed mainly by the operating system, memory and the readiness mechanism. The pool governs a narrower set of operations that cannot be served that way.
Some standard library functions expose the distinction directly. The file system module offers synchronous forms, whose names end in Sync, alongside asynchronous forms. A synchronous read blocks the main thread until the data returns, discarding the benefit of the loop for every other request the process is serving. The documentation advises against synchronous I/O in production server code for that reason, while the synchronous forms remain in ordinary use in command line tools and in start-up code that runs once before a server begins accepting work, where there is not yet anything else to serve. Node.js does not prevent a developer from blocking the loop. It makes the non-blocking form the default shape of its interfaces and leaves the blocking form labelled.
Certain operations block for a different reason. They are not waiting on an external system at all. They occupy the processor — parsing a large JSON document, resizing an image with a pure JavaScript routine, running a long regular expression over user-supplied text, or encrypting a large buffer in a way that runs on the main thread. For those, the remedies are different in kind. The calculation can be divided into smaller pieces that yield to the loop between pieces, moved to a worker thread using the worker_threads module that became stable in Node.js 12, or moved to a separate process altogether. The existence of worker threads does not alter the basic model. Workers have their own event loops and their own JavaScript execution, communicate with the parent by passing messages, and were added for processor-bound work, not as a replacement for asynchronous I/O.
Backpressure and the limits of moving on
Registering work and moving on creates a further problem that a blocking design handles by accident. If a producer generates data faster than a consumer can accept it — a server reading a file faster than a slow client connection can carry it away — an unbounded non-blocking system would accumulate the difference in memory until the process failed. Node.js streams, covered in chapter 9, address this with backpressure. A writable stream signals when its internal buffer has filled beyond a threshold, conventionally through the return value of its write method and the subsequent drain event, and a well-behaved producer pauses until that signal arrives. The pipe and pipeline mechanisms apply the signal automatically. Code that ignores it will still run, and will use memory in proportion to the mismatch, which is one reason throughput figures obtained with a fast local client do not predict behaviour with slow real clients.
The model also changes how errors appear. In blocking code an exception raised by a failed operation surfaces at the call site, in sequence. In callback-based Node.js code an asynchronous failure arrives later, in a different stack, and must be passed explicitly, conventionally as the first argument to the callback. An error that no callback handles does not stop the program at the line that started the operation. It may surface as an unhandled rejection or an uncaught exception long after the initiating code has finished. Much of the later development of the language facilities around Node.js — promises, then async and await — was an attempt to recover sequential readability and reliable error handling without giving up the non-blocking interfaces underneath.
None of this requires the main thread to be faster than the threads in a conventional server. It requires it to spend less of its time waiting. A process that handles ten thousand connections spends most of the life of most of those connections waiting for the next packet, the next database row, or the next file block. Arranging the runtime so that waiting costs a queue entry and an operating system notification, rather than a dedicated thread held for the duration, is the specific mechanical change from which the rest of Node.js follows.
6. npm and the largest package ecosystem
A runtime alone does not make development fast.[7] Most of the work in an ordinary web application is not novel — parsing a request body, validating a form field, talking to a database, hashing a password, formatting a date, serving a file only to a signed-in user. Before package registries became routine, each project obtained that shared work by copying code, by installing libraries through an operating system package manager that knew nothing of the language in use, or by writing the routine again. Node.js acquired, within a year of its first release, a registry and an installer designed for its own modules, and the scale that registry reached changed what a small team could reasonably attempt.
npm takes its name from Node Package Manager, although its operators have long treated the letters as a name in their own right rather than an abbreviation to be expanded. Isaac Z. Schlueter wrote the first version in 2010, working in the same Joyent environment that sponsored Ryan Dahl’s work on Node.js itself, and published it as an open source project. Schlueter later became chief executive of npm, Inc., the company formed in 2014 to operate the registry as a business. GitHub acquired npm, Inc.[8] in March 2020, and npm has since operated as part of GitHub, which is itself owned by Microsoft. The command line tool ships with every standard Node.js installation, so a developer who installs the runtime already has the installer, with no separate step and no choice of competing default to make before the first project begins.
What a package is
A package is a directory of code described by a file named package.json. That file records the package’s name and version, the file that serves as its entry point, the scripts a developer can run, and, most consequentially, its dependencies — the other packages it requires, each with a permitted range of versions. Installing a project reads that file, contacts the public registry at registry.npmjs.org, downloads the named packages, and places them in a directory named node_modules inside the project. A second generated file, package-lock.json, introduced with npm 5 in 2017, records the exact version of every package in the resulting tree, so that a later installation on another machine reproduces the same set rather than resolving the permitted ranges afresh and obtaining newer versions that happen to satisfy them.
Version ranges follow the convention known as semantic versioning. A version number has three parts, major, minor and patch. By convention a patch release fixes defects without changing behaviour that other code may rely on, a minor release adds features while remaining compatible, and a major release may break compatibility. A range written with a caret, such as ^4.18.2, permits installation of later minor and patch releases but not the next major release. The convention is a social agreement as much as a technical one. It works only insofar as package authors classify their own changes honestly, and the lockfile exists in part because that agreement, at the scale of hundreds of transitive dependencies, is not sufficient on its own.
Transitive dependency is the feature and the hazard in one. A developer declares perhaps twenty direct dependencies. Those twenty declare their own, which declare others. A modest web application routinely installs several hundred packages, most of which its author has never named and many of which its author could not identify. Each one was written by somebody solving a small problem once and publishing the solution, and each one spares every later developer from solving it again. The reuse is real. So is the exposure. A defect, a compromised maintainer account, or a withdrawn package anywhere in that tree becomes a problem for every project above it.
The left-pad withdrawal in March 2016
The clearest demonstration arrived on 22 March 2016. A developer removed his packages from the registry following a dispute over a package name. Among them was a package called left-pad, eleven lines of code in its widely reported form, which padded a string to a given length with a chosen character. left-pad was not used directly by most of the projects that failed that day. It sat several levels down in their dependency trees, inside other packages that assumed its presence. When it disappeared, installations across the world began to fail, including builds of widely used development tools. npm restored the package, an unusual step taken, in the company’s own account at the time, because of the scale of breakage in progress.
The episode is often told as a joke about an eleven-line function that nobody needed a library for. The factual point underneath it is more useful. By 2016 the registry had become load-bearing infrastructure for a large part of web development, including projects that did not run Node.js in production at all and used its tooling only to build front-end assets. A naming dispute over one account could interrupt that work within hours. npm subsequently changed its policies on removing published packages, restricting the circumstances in which a package version that others depend on can be withdrawn. The registry’s operators also introduced measures that belong to the ordinary history of any large repository — two-factor authentication for maintainers, introduced and later required for maintainers of the most downloaded packages, automated scanning for known vulnerabilities through npm audit, which arrived with npm 6 in 2018 and reports findings from an advisory database against a project’s lockfile, and provenance attestations, added in 2023, which link a published package to the source repository and build process that produced it through the Sigstore transparency system.
Scale and what it changed
The registry’s own published figures have for several years described it as the largest software registry in the world, with more than two million packages. The figure should be read as the registry operator’s own count, and counts of this kind are not directly comparable between ecosystems that organise code at different levels of granularity — a registry of very small packages will always outnumber one of large libraries. The granularity is itself part of the Node.js story. The culture Schlueter encouraged, and which the module system made easy, favoured publishing small packages that did one thing. A function for padding a string, a function for checking whether a value is a plain object, a function for converting a colour between formats — each could be published, versioned and depended on separately. Critics of that culture pointed, accurately, to trees of hundreds of packages for trivial applications. Defenders pointed, also accurately, to the fact that a tested small package is more reliable than the same function rewritten privately in every project, where it is tested by nobody.
What the scale changed in practice was the starting point of a project. A developer beginning a web service in 2005 assembled a stack from a small number of large components obtained from different places, each with its own installation method, release cycle and documentation. A developer beginning the same service with Node.js runs one command to initialise the project and further commands to add a web framework, a database driver, a validation library, a test runner, a linting tool and a process manager, all from the one registry, all recorded in the one file, all reproducible on a colleague’s machine or a server from the lockfile. The facility is organisational as much as technical. It lowered the cost of trying a library to a few minutes, which increased the number of libraries tried, which increased the number published.
The registry also became the distribution route for tools that are not Node.js libraries in any narrow sense. Compilers and transpilers for other languages, static site generators, the command line tools of cloud providers, and the build tooling for browser applications written in frameworks that never run on a server are all distributed as npm packages, because that is where the developers and the installation habit already were. npx, shipped with npm since version 5.2 in 2017, runs a package binary without installing it permanently, which made the registry a place to fetch a tool for a single use — scaffolding a new project, for instance — as readily as a place to declare a lasting dependency.
Private registries and the commercial layer
Companies that could not publish their internal code to a public registry needed the same mechanism behind their own boundary. npm offered paid private packages and organisations, and alternative registries — GitHub Packages, launched in 2019, and self-hosted registries such as Verdaccio — speak the same protocol, so the same installer can draw public dependencies from one source and internal ones from another according to project configuration. The competing installers that appeared later, notably Yarn, released by Facebook in October 2016 with an emphasis on deterministic installation and speed, and pnpm, which stores packages in a shared content-addressable store and links them into projects to avoid duplicating the same package across many projects on one machine, both consume the same registry and the same package.json format. Their existence indicates where the friction lay — installation speed, disc use and the reproducibility of large trees — without displacing the registry itself, which remained the common source all three installers drew on.
There is a cost recorded in disc space and in attention. A node_modules directory for a substantial project can contain tens of thousands of files and occupy hundreds of megabytes, and copying or scanning it is slow enough to have become a recognised nuisance in backups, containers and continuous integration systems. Auditing a tree of several hundred packages for security and licensing is work that somebody in every organisation must do, usually with automated tooling. Those costs are the other side of the same fact. The ecosystem made other people’s code so easy to obtain that projects came to contain far more of it than their authors wrote, and the work of development shifted in part from writing routines to selecting, trusting and maintaining a set of dependencies.
7. Why the old-style website struggled
The old-style website was not badly made. It was made under a set of arrangements that fitted the web of the 1990s and early 2000s, in which a page was a document, a visit was a sequence of page requests, and the number of people simultaneously connected to a single site was modest. Those arrangements came under strain from two directions at once. Sites were asked to hold far more simultaneous connections, and pages were asked to behave less like documents and more like applications — updating a feed without a reload, showing a message the moment another user sent it, keeping a map or a document or a trading price current. Each strain exposed a different part of the older model. To see why Node.js represented a change rather than a faster version of the same thing, the older model needs describing on its own terms.
The thread-per-request model
The dominant open source web server of that period was Apache HTTP Server, first released in 1995 and for many years the most widely deployed web server on the public internet. In its prefork and worker multiprocessing modules, Apache handled concurrent work by maintaining a pool of processes or threads and assigning one to each incoming connection or request. The assigned thread handled that request from arrival to response. It read the request, ran whatever code generated the page, waited for the database, waited for the file system, assembled the output, sent it, and only then became available for another request.
PHP, created by Rasmus Lerdorf in 1994 and released as PHP/FI in 1995, fitted that model closely and became the most common way to generate dynamic pages on Apache. In the usual deployment, through Apache’s mod_php module or later through a separate FastCGI process manager, each request started PHP, loaded the application’s code, connected to the database, built a complete HTML page, sent it, and ended. The interpreter’s state was discarded between requests — the model its documentation called shared-nothing. That design had genuine virtues. A fault in one request did not corrupt the state of the next, because there was no continuing state to corrupt. A developer could reason about a script as a self-contained programme that began, did its work and finished. Scaling the code was conceptually simple, because any server could take any request.
The cost was in what each concurrent request consumed and in what it did while waiting. A thread is not free. It carries a stack, conventionally allocated in megabytes even where the memory actually committed is smaller, plus the interpreter and application state attached to that request. A pool configured for a few hundred simultaneous threads sets a hard ceiling on simultaneous work regardless of how little those threads are doing. When the pool filled, further connections queued or were refused, even though the machine’s processor might be nearly idle. Most of the threads, most of the time, were not computing. They were waiting — for a database query to return, for a file to be read, for another service on the network to answer. The server paid the full cost of a thread for the whole duration of a wait it did not control.
This is the problem that Daniel Kegel described in an essay first published in 1999 and updated through the following years as the C10k problem — the difficulty of handling ten thousand simultaneous connections on one machine.[9] Kegel’s point was not that hardware was too slow. It was that software organised around a thread or process for each connection, with blocking calls inside each thread, used its resources in proportion to the number of connections rather than in proportion to the amount of work those connections actually required at any given moment. Ten thousand mostly idle connections should not, in principle, require ten thousand threads. In the thread-per-request model, they effectively did.
Operators had answers, and used them for years. They raised thread and process limits until memory ran out. They put a lightweight server such as nginx, released by Igor Sysoev in 2004 and built around an event-driven model of its own, in front of Apache to hold connections and pass only active requests onwards. They added caching layers so that many requests never reached PHP at all, and they bought more machines. Each answer worked at a price. More machines meant more licences in commercial stacks, more deployment targets, more database connections — because each PHP process typically opened its own connection to the database, the database itself could become the ceiling, with its own per-connection memory and process costs. The architecture could be made to scale. It scaled by adding resources in rough proportion to connections, including idle ones.
Blocking input and output as the default
Inside the request, the code was blocking in the ordinary sense described in chapter 5. A line that queried the database did not return until the database answered. A line that called an external service — a payment provider, a mapping service, another site’s interface — held the thread for the full round trip. A page that needed five such calls made them in sequence and took at least the sum of their durations, thread occupied throughout. Nothing in the model encouraged doing otherwise, because the language and the framework presented each call as a straightforward function that returned a value. The simplicity was the attraction. It was also why a single slow dependency could slow every page that touched it and consume the pool while doing so, a failure pattern operators knew well — one struggling database, threads accumulating behind it, the pool exhausting, and a site that stopped responding to requests that did not involve the database at all.
Separate languages for separate layers
The older stack divided its work between languages that did not share code, data structures or developers. The server ran PHP, or Perl, or Java, or a Microsoft language. The database was addressed in SQL. The page delivered to the browser was HTML and CSS, and any behaviour in the browser was written in JavaScript, which before the late 2000s was often treated as decoration — a menu effect, a form check — rather than as part of the application. A single feature, such as validating an address entered in a form, was commonly implemented twice. The browser validated it in JavaScript so the user received an immediate response without a round trip. The server validated it again in PHP, because input from a browser cannot be trusted. The two implementations were written separately, in different languages, by possibly different people, and could and did drift apart, so that data accepted in the browser was rejected by the server, or the reverse.
Data crossing between the layers changed form at each boundary. A database row became a PHP structure, which was printed into HTML as text, which the browser parsed, from which JavaScript extracted values again. The format that later standardised much of this exchange, JSON — JavaScript Object Notation, specified by Douglas Crockford in the early 2000s and formalised as RFC 4627 in 2006 — was native to none of the server languages of the period.[10] Each had to parse and generate it through a library. The friction was not any single conversion. It was that every feature paid all of them, and that the team’s knowledge divided along the same lines, with front-end and back-end developers working in different languages, different tooling and often different release cycles on what the user experienced as one product.
The full page reload
Interaction followed the document model. A user clicked a link or submitted a form. The browser discarded the current page, sent a request, waited, received a complete new page — the same header, navigation, sidebar and footer as the page just left, surrounding the one part that had changed — and rendered it from the top. Scroll position and transient state were lost unless the application took specific steps to preserve them. The server regenerated everything, including the parts that had not changed, and the network carried all of it again.
Techniques to avoid that pattern existed and were in use well before Node.js. Microsoft introduced the XMLHttpRequest mechanism in Internet Explorer 5 in 1999 for Outlook Web Access, and other browsers adopted it. Jesse James Garrett gave the resulting approach a name, Ajax, in an essay published in February 2005, after Google had shown its possibilities in Gmail in 2004 and Google Maps in 2005 — pages that fetched data in the background and updated part of the display without a reload. But Ajax in an old-style stack was an addition to the document model, not a replacement for it. The server still tended to think in pages. Background requests were often served by separate scripts returning fragments of HTML or hand-built data, bolted onto an application whose routing, templates and session handling assumed a full page per request. The more application-like the page became, the more its centre of gravity moved into JavaScript in the browser, and the more awkward the division of labour described above became — the substantial part of the product was now being written in the language the server could not run.
Polling for a web that could not push
Nothing in the older model let a server initiate contact. HTTP is a request and response protocol. The browser asks, the server answers, the exchange ends. A page that needed to know when something changed — a new message, a new bid, a changed price — had no standard way to be told. It asked repeatedly. That practice, polling, meant the browser sent a request every few seconds asking whether anything was new, and in the great majority of cases the answer was that nothing was. Each poll consumed a request, a thread for its duration, a database query, and bandwidth, and it still delivered the update late by up to the polling interval. Shortening the interval improved freshness and multiplied the waste in direct proportion. Lengthening it saved resources and made the site feel stale.
The workarounds each carried their own cost against the thread-per-request model. Long polling held a request open until the server had something to send or a timeout approached, which improved freshness but kept a thread occupied doing nothing for the duration — precisely the resource that model could least afford to hold idle, so a feature used by many simultaneous visitors could exhaust a pool on its own. Server-sent events and, later, the WebSocket protocol, standardised as RFC 6455 in December 2011, provided a connection the server could write to at any time, but a server organised around short-lived page requests and discarded state was not organised to hold tens of thousands of such connections open indefinitely. The demand was for persistent connections. The architecture’s unit of work was a brief request. Those two facts were in direct tension.
What Node.js changed, stated plainly
Node.js did not make any of those problems disappear. Databases still answer at their own speed, slow dependencies still slow the pages that wait for them, and validation still has to happen on the server however it is written in the browser. What changed was the allocation of resources against those facts. A Node.js process holds a connection as a data structure and an entry in the operating system’s readiness list, not as a dedicated thread, so ten thousand mostly idle connections cost memory for their state rather than ten thousand stacks. Waiting on I/O returns the main thread to other requests instead of occupying it, so the same process does useful work during the waits that filled an Apache pool. A persistent connection for a WebSocket or a server-sent events stream is a natural object in a long-running event-driven process, rather than a request that refuses to end. And because the runtime is JavaScript, the code that validates in the browser and the code that validates on the server can be the same code, in the same language, drawing on the same package registry — the subject of the next chapter.
The comparison should not be overstated in the other direction either. Apache and PHP did not stand still. PHP gained a process manager, later versions of the language became substantially faster, and event-driven PHP frameworks adopted asynchronous models. Apache offered an event multiprocessing module. nginx and other event-driven servers took a large share of high-connection work. Many high-traffic sites continued to run on those stacks, and continue to run on them, at very large scale. The historical claim is narrower and better supported. The old-style arrangement made concurrency expensive, real-time behaviour an addition rather than a foundation, and the browser’s language a separate world from the server’s. Node.js was designed, from 2009, with the opposite defaults on all three.

8. One language across the whole stack
The most frequently repeated claim made for Node.js is also the simplest to state and the easiest to exaggerate — that it lets a developer use one language, JavaScript, on the server as well as in the browser. The claim is true in a literal sense. A team can write its HTTP server, its build tooling, its tests and its browser interface in JavaScript or in TypeScript, the typed extension of the language that compiles to JavaScript, and can share some code between those places unchanged. What that actually buys, and what it does not, is worth separating, because the benefit is not that JavaScript is uniquely suited to every layer. It is that the boundaries between layers stop also being boundaries between languages.
What can genuinely be shared
Some code is indifferent to where it runs. Validation rules are the standard example, and the one that mattered under the older arrangement described in chapter 7. A rule that a postcode must match a pattern, that a date of birth must lie in the past, that a basket must contain at least one item — expressed once as a JavaScript function or as a schema in a library such as Zod or Joi, both distributed through npm — can run in the browser to give the user an immediate response and on the server to give the application an authoritative one. The two checks are no longer two implementations that must be kept in agreement by discipline. They are the same file, imported in both places, changed in one commit, tested by one test.
The same applies to the shapes of data. An application’s interface between browser and server is usually a set of JSON documents. JSON began as a notation derived from JavaScript object syntax, and in JavaScript it requires no mapping layer. A response body parsed with JSON.parse becomes the object the rest of the code works with, with the same field names and nesting as the object the server assembled with JSON.stringify. In a language where data arrives as objects of a class defined separately from the wire format, somebody writes and maintains the correspondence between the two, field by field, and that correspondence is a recognised source of defects when one side changes. In JavaScript the correspondence is largely the thing itself. TypeScript, released by Microsoft in October 2012 and adopted widely in Node.js development over the following decade, strengthens this by letting a single type definition describe a data shape and be checked at compile time on both sides of the interface, while the running code remains JavaScript.
Formatting and business rules travel the same way. A function that calculates a price with a discount and a tax rate, a routine that formats a date for display, a set of constants naming the states an order can be in, the logic that decides which fields of a form are required given the answers already supplied — all of these can live in a shared package inside a project rather than being written twice. Utilities for the manipulation of strings, arrays and dates, and libraries for working with time zones and currencies, are obtained once from npm and used in both environments. Isomorphic was the word used in the early 2010s for code of this kind, later largely replaced by the plainer term universal. The fashion for the word passed. The practice remained, because it removed work rather than adding it.
Rendering on both sides
The clearest application was rendering. A web application framework of the older kind produced HTML on the server and then, increasingly, handed control to JavaScript in the browser that re-created parts of the same display from data. The two renderings were written in different template languages against different models of the same page. React, the interface library released by Facebook in May 2013, made a component — a unit of interface described in JavaScript — the thing that rendered. Because Node.js could run that same JavaScript outside a browser, a component could be rendered to HTML on the server for the first response, sent to the browser, and then taken over by the same component running there, a process called hydration. The user received a complete page quickly, including for search engines and for slow devices, without the project maintaining a second rendering of it in a server template language.
Frameworks were built on that possibility. Next.js, released by the company then called Zeit and now Vercel in October 2016, organised a React application so that pages could be rendered on the server by Node.js, generated in advance as static files, or rendered in the browser, within one project and one language. Nuxt did the equivalent for the Vue framework, and SvelteKit later for Svelte. In each case the arrangement depends on the server runtime and the browser running the same language and, in large part, the same code. It is not available, in that direct form, where the server is written in PHP or Java and the interface in JavaScript. Those stacks server-render in their own language and hand over to a different one, which is workable and widely done, but the hand-over is a translation rather than a continuation.
One toolchain, one team
The less visible saving is in tooling. A Node.js project has one package manager and one package.json describing the dependencies of the server code, the browser code and the development tools together. It has one linting configuration, checking style and common errors across all of it, one formatter, one test runner capable of testing server functions and interface components in the same run, and one build step that compiles, bundles and prepares both halves for deployment. Under the older arrangement a project of any size had two of most of those, maintained separately, with version constraints that had nothing to do with each other. Build tooling itself came to be written in JavaScript and run by Node.js even for projects whose server was something else — task runners such as Grunt, released in 2012, and Gulp in 2013, then bundlers such as webpack, whose first releases appeared in 2014, and Browserify before it, which existed specifically to let browser code use the Node.js module system and npm packages. For several years a large number of PHP, Ruby and Java projects had a package.json in their repository purely to build their front end. The toolchain had standardised on Node.js before many of the servers had.
For teams, the consequence was organisational. The division between a front-end developer who could not work on the server and a back-end developer who could not work on the interface was a division of language before it was a division of skill. A JavaScript developer on a Node.js stack can read the whole codebase, move a validation rule from one side to the other, trace a defect from a click in the browser through the request to the database query and back, and be on call for the whole of it. Smaller organisations in particular gained from that. A company with four developers could not always staff two specialisms and the boundary between them. Hiring drew on one pool — and JavaScript, by the measure of the annual Stack Overflow developer surveys through the 2010s and into the 2020s, was the most commonly used programming language among respondents in every year of that period, which made that pool the largest one available. Those surveys are self-selecting samples of their own readership and should be read as such, but the direction of the finding was consistent across many years and matched the observable fact that every web developer already had to know some JavaScript for the browser, whether or not they liked it.
The limits of one language
The browser and the server are not the same environment, and sharing a language does not make them so. Browser code has access to the document, the window and the display, and no access to the file system or the database. Server code has the reverse. A shared module that accidentally imports a Node.js-only library cannot run in the browser, and bundlers spend part of their effort detecting and shimming exactly such mismatches. Environment variables, secrets and database credentials must never be shipped to the browser, and frameworks maintain explicit conventions — variable name prefixes, separate server-only modules — to prevent code or values intended for the server being bundled into what is sent to every visitor. Developers still have to know which side a given file will run on. The language is shared. The platform is not.
Nor does one language mean one language for everything an organisation does. Data analysis, machine learning, systems programming and much mobile development continued in other languages, and a Node.js application commonly sits alongside services written in Python, Go, Java or Rust, communicating over network interfaces. JavaScript itself is not a natural choice for heavy numerical work on the server, for the processor-bound reasons set out in chapter 5. The claim that survived contact with practice is a modest one. Within the boundaries of a web product — the interface, the server that serves it, the interface between them, and the tools that build and test both — a single language removes a translation layer that the previous generation of stacks paid for on every feature, in duplicate validation, in data mapping, in double tooling and in divided teams. That removal, repeated across thousands of small decisions in a project’s life, is where most of the facility attributed to Node.js is actually located.
9. Real-time and streaming by design
The earliest web applications moved in one direction and at one pace. A browser asked for a page, a server assembled it, and the connection closed. If the underlying information changed a second later, the page on screen knew nothing about it until somebody pressed refresh. That arrangement was adequate for documents, catalogues and order forms. It was poorly suited to a chat window, a shared document, a price feed, a dispatch board or a game, where the useful life of a piece of information can be measured in seconds and where the server, not the visitor, often has the news first.
Developers worked around the limitation before they could remove it. The simplest workaround was polling, in which the browser asked the server at fixed intervals whether anything had changed. Polling wasted most of its requests. A client checking every five seconds for a message that arrived twice an hour generated thousands of empty answers for every useful one, and each request carried the full cost of opening a connection, sending headers and being routed through application code. Shortening the interval reduced delay and increased waste in the same proportion. Lengthening it saved resources by making the application visibly stale.
Long polling, popularised during the 2000s under names including Comet, improved the trade without removing it. The browser sent a request and the server held it open, answering only when an event occurred or a timeout approached. The client then processed the answer and immediately asked again. Long polling delivered news promptly and avoided most empty responses, but it occupied a connection and, in a threaded server, a thread, for the whole of each wait. A service with ten thousand idle visitors was therefore holding ten thousand threads open to do, for most of the time, nothing at all. That cost is the point at which the design described in chapter five stopped being an optimisation and became the condition that made a class of applications practical.
Connections that wait without consuming a thread
A Node.js process holds an open connection as state rather than as a thread at work. The event loop registers an interest in a socket, moves on to other tasks, and returns when the operating system reports that the socket has data, has closed or can accept more output. Ten thousand visitors waiting for a message therefore impose memory costs, for the socket objects and whatever application data is attached to them, but they do not impose ten thousand stacks or ten thousand scheduled threads. The distinction mattered commercially as much as technically. Real-time features had usually been treated as additions to a conventional application, sometimes running on separate infrastructure maintained for that purpose. In Node they could be written in the same process, in the same language and against the same data, as the rest of the service.
The transport that completed this picture was WebSocket.[11] Work on the protocol began in the late 2000s as part of the HTML5 effort, and the Internet Engineering Task Force published it as RFC 6455 in December 2011. A WebSocket connection begins as an ordinary HTTP request carrying an upgrade header. If the server agrees, the connection changes protocol and thereafter both ends can send small framed messages at any time, in either direction, over the single connection that is already open. There is no repeated request, no repeated header block and no need for the client to ask whether anything has happened. Framing overhead on a server message can be as little as two bytes.
Browser support arrived over the following two years, and Node acquired libraries at each layer of the problem. The ws library, first released in 2011, provided a fast, close-to-the-protocol implementation. Socket.IO, created by Guillermo Rauch and released in 2010 before the protocol itself was settled, took the opposite approach and abstracted the transport away. A Socket.IO application was written against events, named messages and rooms, which group connections so that a message can be sent to every member of a chat room or a project without the application tracking each socket itself. Where WebSocket was unavailable, as it still was in older browsers and some corporate networks, Socket.IO fell back to long polling and upgraded the connection when it could. Its companion component Engine.IO handled that negotiation layer. The fallback machinery dates the library to a transitional period, but it explains its rapid adoption. Developers could write the real-time part of an application once, in 2011 or 2012, and serve visitors whose browsers differed by several years of standards work.
Server-Sent Events occupied the narrower ground that many applications actually needed. Standardised as part of HTML5 and supported in most browsers by the middle of the 2010s, it allows a server to send a stream of text events over an ordinary HTTP response that simply does not end. It carries no client-to-server channel, so it cannot replace WebSocket for chat or games. For notifications, progress reports, news feeds and live scores it has compensating advantages. It runs over standard HTTP infrastructure, reconnects automatically after a dropped connection and can be implemented in Node by writing formatted lines to a response object and leaving it open. A considerable share of what is marketed as real-time is one-way, and for that share the simpler mechanism is often the more durable one.
Streams as a core abstraction
Real-time communication is about connections that stay open. Streaming, in the sense Node uses the word, is about data that is processed in pieces rather than whole. The two ideas share a foundation, since both assume that a program should react to data as it arrives instead of waiting for a complete body of work to assemble itself, but the stream abstraction is older than Node and broader than the web. Unix had embodied it in the pipe since the 1970s, connecting the output of one program to the input of another so that a file of any size could be processed in a buffer of fixed size.
Node placed streams near the centre of its standard library from the early releases.[12] A readable stream produces data, a writable stream consumes it, a duplex stream does both and a transform stream modifies data as it passes through. Files, network sockets, HTTP requests and responses, compression and encryption are all presented in these terms. An HTTP request received by a Node server is a readable stream, which is why a large upload need not be held in memory before the application sees its first byte. The response is a writable stream, which is why a server can begin sending a page, a file or a generated report before the last part of it exists.
The practical consequence is a ceiling on memory that does not depend on the size of the input. Copying a two-gigabyte file with streams uses a buffer measured in kilobytes, because each chunk is read, written and released in turn. Loading the same file whole, the obvious approach in a framework that presents a request or a file as a completed value, requires two gigabytes. The same arithmetic governs proxying, log processing, image and video handling, database exports and the compression of responses. The pipe method, which connects a readable stream to a writable one, reduced the common case to a single line and made the efficient pattern also the shortest one to write.
The difficult part of streaming is the mismatch of speeds, and Node’s history here is instructive because the first design got it visibly wrong. If a fast producer feeds a slow consumer, unprocessed chunks accumulate in memory until the process fails. This is backpressure, the mechanism by which a consumer signals that it cannot accept more data yet. Early Node streams, later called Streams1, pushed data at the consumer whether it was ready or not, and pausing them was unreliable. The rewritten implementation that arrived in Node 0.10 in March 2013, known as Streams2, changed readable streams to a pull model in which the consumer requests data and the runtime delivers it when available. A further revision in Node 0.12 refined the handling of streams that produce data in discrete objects rather than bytes. The rewrite broke some existing code and was argued over for much of 2013, but it established the behaviour on which the rest of the ecosystem depends. When a writable stream’s internal buffer passes a defined threshold, its write method returns false, the producer pauses, and writing resumes on the drain event. The pipeline function, added in Node 10 in 2018 and later given a promise-based form, wires that negotiation together and handles errors and premature closure across the whole chain rather than at each joint separately.
Where the two ideas meet
Audio and video made the combination familiar to people who never read the documentation. A media file served through Node does not need to be downloaded before playback begins, because the server can answer a request for a byte range with the corresponding chunk of the file, streamed from disk, and continue supplying chunks as the player consumes them. Progress reporting follows the same shape. A long operation such as a report generation, a bulk import or a software build can write status events to an open response as each stage completes, so the visitor sees movement within a second instead of a spinner that resolves, minutes later, into either success or a timeout. Downloads of generated files can begin before generation finishes. Log data can be compressed, encrypted and written to storage in one pass, with no intermediate file and no point at which the whole log exists in memory.
The pattern also changed what a server could forward. A Node process placed between a browser and an internal service can stream a response through, inspecting or modifying it in a transform stream, without buffering the body. That property underlies a large amount of unglamorous infrastructure. Proxies, API gateways and the development servers described in chapter twelve all rely on it, as do the server-rendering frameworks of chapter ten when they send a page to the browser in sections, allowing the browser to display the shell of a page while slower components are still being prepared on the server. React’s server rendering acquired exactly this capability through streaming, and the frameworks built on it expose it as a routine feature rather than a specialist one.
Later additions brought Node’s streams into line with the version of the abstraction that browsers were standardising. The WHATWG Streams specification, developed for the web platform, defines readable and writable streams with a different interface from Node’s own. Node shipped an implementation experimentally in version 15 in 2020 and made it available globally in version 18 in April 2022, so code written for the browser’s fetch and stream APIs could run on the server without translation, and a response body received in Node could be handled with the same methods on both sides of the connection. HTTP/2, published as RFC 7540 in May 2015 and supported in Node from version 8.4 in August 2017, added multiplexed streams within a single connection at the protocol level, a separate use of the word that nevertheless points the same way. The direction of travel across two decades of protocol and library work is consistent. Data moves in pieces, connections stay open, and the program reacts when something arrives rather than asking, repeatedly, whether anything has.
Try it — a Node server in full
The sample application prepared for this essay makes the chapter’s three claims testable in a few minutes. Its server, reproduced in full below, uses no external packages at all — only Node’s built-in http, fs and path modules. It serves the page itself, answers a small notes application programming interface at /api/notes for reading and adding notes, pushes each new note to every connected browser at once through Server-Sent Events at /api/live with no polling and no page reload, and answers /api/event-loop with the order in which synchronous code, process.nextTick, a promise, a timer and a file operation actually ran, so the event loop described in chapter five can be watched rather than taken on trust. Run locally it needs two commands, npm start in its folder and then a browser opened at http://localhost:3000.
// The Brilliance of Node.js — reader sample app
// Zero dependencies. Built-in http only, so it runs anywhere Node runs.
// Try: node server.js then open http://localhost:3000
const http = require('http');
const fs = require('fs');
const path = require('path');
const notes = [{ id: 1, text: 'Node runs this API, the page and the live stream — one language.' }];
let nextId = 2;
const streamClients = new Set();
function sendJson(res, status, data) {
const body = JSON.stringify(data);
res.writeHead(status, { 'Content-Type': 'application/json' });
res.end(body);
}
function broadcast(event, data) {
const payload = `event: ${event}ndata: ${JSON.stringify(data)}nn`;
for (const res of streamClients) res.write(payload);
}
const server = http.createServer((req, res) => {
const url = new URL(req.url, 'http://localhost');
// 1. A tiny API — same language as the browser code that calls it
if (url.pathname === '/api/notes' && req.method === 'GET') return sendJson(res, 200, notes);
if (url.pathname === '/api/notes' && req.method === 'POST') {
let body = '';
req.on('data', c => body += c);
req.on('end', () => {
try {
const note = { id: nextId++, text: (JSON.parse(body).text || '').slice(0, 200) };
if (!note.text) return sendJson(res, 400, { error: 'text required' });
notes.push(note); broadcast('note', note); return sendJson(res, 201, note);
} catch { return sendJson(res, 400, { error: 'invalid JSON' }); }
});
return;
}
// 2. Live stream — Server-Sent Events, no polling, no page reload
if (url.pathname === '/api/live') {
res.writeHead(200, { 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache', Connection: 'keep-alive' });
res.write(`event: hellondata: ${JSON.stringify({ notes: notes.length, at: new Date().toISOString() })}nn`);
streamClients.add(res);
const tick = setInterval(() => res.write(`event: tickndata: ${JSON.stringify({ at: new Date().toISOString(), clients: streamClients.size })}nn`), 2000);
req.on('close', () => { clearInterval(tick); streamClients.delete(res); });
return;
}
// 3. Event loop demo — watch the order: sync, nextTick, promise, timer, I/O
if (url.pathname === '/api/event-loop') {
const order = [];
order.push('1 sync start');
setTimeout(() => order.push('setTimeout 0ms — timers phase'), 0);
setImmediate(() => order.push('setImmediate — check phase'));
process.nextTick(() => order.push('2 process.nextTick'));
Promise.resolve().then(() => order.push('3 promise'));
fs.readFile(__filename, () => { order.push('file I/O callback — poll phase'); setTimeout(() => sendJson(res, 200, { order }), 30); });
order.push('4 sync end — the loop was never blocked');
return;
}
// Static page
const file = url.pathname === '/' ? 'index.html' : url.pathname.slice(1);
const full = path.join(__dirname, 'public', file);
if (!full.startsWith(path.join(__dirname, 'public'))) { res.writeHead(403); return res.end('Forbidden'); }
fs.readFile(full, (err, data) => {
if (err) { res.writeHead(404); return res.end('Not found'); }
res.writeHead(200, { 'Content-Type': file.endsWith('.html') ? 'text/html' : 'text/plain' });
res.end(data);
});
});
server.listen(process.env.PORT || 3000, () => console.log(`Sample app running at http://localhost:${process.env.PORT || 3000}`));
The live chat below, The Node Room, runs on the same principles — one Node.js process, live messages pushed to every reader at once, a poll and a quiz counted as they happen, and nothing stored in a database. It is the sample app grown up, and it is running now.
10. Frameworks and the shape of modern development
Node’s built-in HTTP module can serve a complete application, and in the runtime’s first years a fair number of developers wrote directly against it. Doing so meant handling routing, the parsing of request bodies, cookies, file serving and error responses by hand, in every project, in much the same way. A framework, in this context, is a library that supplies those recurring parts in a settled form and leaves the developer the parts that differ between applications. The history of Node frameworks is therefore not a succession of fashions. It is the record of successive decisions about how much of that recurring work should be supplied, and how firmly its shape should be prescribed.
The first widely adopted answer was Connect, released in 2010 by Sencha and developed substantially by Tim Caswell. Connect introduced the middleware pattern that still organises much of Node development. A middleware is a small function that receives a request, a response and a means of passing control to the next function in a chain. Logging, compression, session handling and static file serving each become one link. An application is then a sequence of such links, executed in order, with the route handler at the end. The pattern suited the runtime’s character precisely because each link is small, does one thing and hands over control as soon as it is waiting on something else.
Express and the minimal framework
Express, created by TJ Holowaychuk and first released on 16 November 2010, built routing and an application structure on top of that idea, drawing openly on Sinatra, the small Ruby framework of 2007.[13] An Express application declares routes as a method and a path paired with a handler, mounts middleware in a defined order and renders responses through a pluggable view engine, of which Jade, later renamed Pug, and EJS were the common early choices. Express prescribed almost nothing beyond that. It had no built-in database layer, no required project layout and no opinion about how the application should be organised past the entry file.
That restraint explains both its longevity and the criticism it attracts. A developer could learn the core of Express in an afternoon and have a working service the same day, which made it the default teaching framework and the default choice in the tutorials, books and starter projects through which most developers first met Node. An ecosystem of middleware accumulated around it, so that authentication, validation, file uploads and rate limiting were available as packages rather than features awaiting a release. The same restraint meant that two Express applications of any size could be organised quite differently, and that decisions a larger framework would have taken once had to be taken again, project by project and team by team.
Express also illustrates the maintenance problem that open-source infrastructure creates. Holowaychuk transferred the project in 2014, and stewardship passed to StrongLoop and then, after IBM acquired StrongLoop in September 2015, into the orbit of the Node.js Foundation. Version 4, released in April 2014, had already unbundled most middleware into separate packages so that each could be updated on its own schedule. Version 5 then spent an unusually long time in preparation after an early alpha in 2014, reaching a full release only in October 2024, by which point its changes were deliberately conservative. Throughout that decade Express remained, by download count and by survey responses, among the most used web frameworks in any language. The episode is worth noting because the alternative account, in which frameworks rise and are replaced within a few years, does not fit the largest case in Node’s own history.
Frameworks that prescribed more
The reaction against minimalism produced frameworks that took decisions on the developer’s behalf. Hapi, created by Eran Hammer at Walmart Labs and released in 2011, began as part of an attempt to build on Express and diverged into a configuration-led design in which routes, validation and plug-ins are declared as objects rather than assembled from middleware calls. It carried its origins with it. A framework built inside a large retailer had to satisfy security review and operational requirements that a small project could defer, and hapi’s plug-in system and built-in input validation reflected that.
Koa, announced in 2013 by several of the developers behind Express, moved in the opposite direction on size while agreeing that Express had reached a limit. Its core is smaller than Express’s, with routing and templating left to separate packages, and its design was organised around the newer language features then arriving in JavaScript. Middleware in Koa wraps the code that follows it, so a single function can act before and after the rest of the chain runs, which made timing, logging and error handling cleaner to express. Koa’s practical influence was larger than its market share. It normalised the style of middleware that the async and await syntax, covered in chapter thirteen, would shortly make available to every framework.
Fastify, created by Matteo Collina and Tomas Della Vedova and first released in September 2016, addressed a different cost. Where Express treated performance as adequate and flexibility as the priority, Fastify was built around the overhead of the framework itself. It validates incoming and outgoing data against JSON Schema, which allows it to check a request and to serialise a response by generating code from the schema rather than by inspecting each object at run time. Its authors published the benchmarks behind their claims and maintained a public comparison against other frameworks, and its plug-in system encloses each plug-in’s dependencies so that a large application can be divided without the parts interfering. Fastify reached its first stable major version in 2018 and became the common recommendation for Node services where request throughput, rather than familiarity, was the deciding factor.
NestJS, created by Kamil Myśliwiec and released in 2017, is the clearest statement of the prescriptive position. Written for TypeScript and borrowing its structure of modules, controllers and injectable providers from Angular, it gives a team a fixed architecture, a dependency injection system and conventions for testing, and in exchange it removes most structural decisions from the project entirely. Restify, from 2011, served the narrower field of pure API services. LoopBack, released by StrongLoop in 2013, generated APIs from data models. Meteor, which predates most of this history as a full-stack platform released in 2012, attempted to supply the client, the server and the synchronisation between them as one product. Each of these is a different answer to the same question, and the fact that all of them found an audience is the useful fact. Node never acquired a single official framework, so the choice itself became part of the discipline, and projects are still described, accurately, by naming the framework they settled on.
Rendering on the server again
The second generation of frameworks answered a problem created by the success of the first, together with the rise of browser-side rendering described in chapter seven. By the middle of the 2010s many sites were being delivered to the browser as an empty page plus a large bundle of JavaScript, which then fetched its data and built the page on the visitor’s machine. The approach gave developers a responsive interface and gave visitors a delay, a blank screen and, on a slow connection or a modest phone, a long wait before anything could be read or pressed. Search engines, which had indexed HTML, also had to execute JavaScript to see the content at all.
Next.js, announced by the company then called ZEIT, now Vercel, on 25 October 2016 and developed under Guillermo Rauch, applied Node to that problem for React applications.[14] A Next.js project places files in a directory and thereby defines its routes, and Node renders each page to HTML on the server before sending it, after which the browser takes over the rendered page and makes it interactive in a process called hydration. The visitor receives readable content with the first response, and the developer keeps the component model of a browser application. Later versions added static generation at build time, incremental regeneration of individual pages after deployment and, in Next.js 13 in October 2022 and the stable App Router of Next.js 13.4 in May 2023, a model of server components in which parts of a page are rendered only on the server and never shipped to the browser as JavaScript at all.
Equivalent frameworks formed around each of the other browser libraries, usually within a short interval. Nuxt, released in 2016, did the same work for Vue. SvelteKit, announced in October 2020 and released in its first stable version in December 2022, did it for Svelte, whose compiler already removed much of the run-time code other frameworks sent to the browser. Remix, founded in 2020 by two of the authors of React Router, opened its source in November 2021 and was acquired by Shopify in October 2022, argued for returning to web fundamentals, using standard request and response objects and letting the browser’s own form and navigation behaviour carry more of the load. Astro, released in 2021, took the reduction furthest for content sites, shipping no JavaScript by default and adding interactive components only where a page specifically required them.
Two features unite this generation and distinguish it from Express and its contemporaries. The first is that the framework, not the developer, decides where each part of a page runs, and can move a component between server, build machine and browser as the code changes. The second is that the boundary is invisible in the source. A developer writes a component that reads data and displays it, and the framework determines that the reading happens in Node and the display begins there too. That is the arrangement chapter eight described as one language across the stack, carried one step further, into one component model across the stack. It is also the arrangement that made Node a requirement rather than an option for a large class of projects. A team that chose React for the browser in 2018 and wanted its pages rendered before they were sent had, in practice, chosen Node for the server at the same time, whether or not the decision was ever written down.
11. Node at scale in production
Benchmarks establish what a runtime can do on a machine set aside for the purpose. Production accounts establish something harder to obtain, which is what happened when the runtime carried a service that a company depended on for revenue, on ordinary days and on the worst days of its year. Node accumulated such accounts unusually early, and it accumulated them at companies large enough that their engineering decisions were reported and examined. The accounts below are drawn from those companies’ own engineering publications and from the case studies published by the Node.js project. Where a figure comes from the company describing its own system, it is identified as self-reported, and it should be read as the company’s measurement of its own migration rather than as an independent comparison of runtimes.
LinkedIn and the mobile server
LinkedIn was among the first large companies to commit publicly, and its case remains the clearest statement of the original argument.[15] In 2011 LinkedIn rebuilt the server behind its mobile applications, moving from Ruby on Rails to Node. Kiran Prasad, who led LinkedIn’s mobile engineering, described the reasoning in interviews given that year. The mobile server spent most of its time waiting, aggregating responses from internal services and returning them to the phone, which is precisely the workload at which a threaded server holds resources idle and an event-driven server does not.
LinkedIn reported, as its own figures, that the new service ran on far fewer machines, with the number of servers for that function falling from thirty to three, and that it was between two and twenty times faster than its predecessor depending on the operation, with the largest gains on the requests that combined several internal calls. The company also reported a development benefit that recurs in every later account in this chapter. Its mobile team already wrote JavaScript for the client side of its products, so the same engineers could work on the server without changing language, and features that had previously required coordination between two groups could be built by one. LinkedIn’s scale at the time was not marginal. It was serving tens of millions of members, and the mobile service was the fastest-growing part of its business.
PayPal and the parallel build
PayPal’s account, published on its engineering blog in November 2013 by Jeff Harrell under the title “Node.js at PayPal”, is the most methodical of the early reports because PayPal did not simply migrate. It built the same application twice. A team rebuilt one of PayPal’s core account-facing applications in Java, as the company’s established practice required, while a second team of two engineers built a version in Node as an experiment, initially as a prototype that was not expected to reach production.
The Node version reached production first, and PayPal published the comparison as its own reported results. It stated that the Node application was built almost twice as fast with fewer people, contained 33 per cent fewer lines of code and 40 per cent fewer files than the Java version, handled double the requests per second per core, and reduced the average response time for the same page by 35 per cent. Those figures describe one application, one pair of teams and one company’s code, and PayPal presented them in those terms. Their influence was out of proportion to their scope because they answered the objection most often raised against Node in 2013, which was not that it was slow but that it was unsuitable for a regulated financial business with an established Java estate. PayPal went on to release its own supporting framework, Kraken.js, built on Express, as open source, and to move further public-facing applications onto Node in the following years.
Walmart, hapi and the busiest day of the year
Walmart tested the runtime against the sharpest peak in retail. Eran Hammer and the Walmart Labs team put Node into production for the company’s mobile services in 2012, a decision Hammer described at the time as a deliberate risk taken because the mobile workload, many small requests from phones requiring data assembled from several internal systems, matched Node’s strengths. The team’s framework work became hapi, covered in chapter ten, and its validation and security requirements were shaped by the fact that the code would run for a retailer of Walmart’s size.
The test that mattered was Black Friday, the day after Thanksgiving and the busiest shopping day of the American year. Walmart reported after Black Friday 2013 that its Node-based mobile services had handled the day’s traffic without the failures that such peaks had previously caused, and Hammer reported that the servers concerned ran at a small fraction of their capacity during the peak, a figure he gave as around 1 per cent of CPU on the Node tier at points during the day. That figure is self-reported, from a talk by the engineer responsible, and it refers to one tier of a much larger system rather than to Walmart’s infrastructure as a whole. Read within those limits it makes a specific point. A tier that brokers requests between phones and internal services spends its time waiting on those services, so its processors are idle even at peak load, and the correct measure of its capacity is the number of connections it can hold rather than the computation it can perform. Walmart subsequently open-sourced more of its Node tooling and described running its core e-commerce platform for walmart.com on Node-based services in the years that followed.
Netflix and the interface layer
Netflix adopted Node at a different layer and for a different reason. The company began moving the user interface of netflix.com onto Node in 2013 and described the work publicly in 2015, after the website’s interface had been rebuilt as a single-page application served and partly rendered by Node. Netflix’s problem was not request brokering but duplication. Its interface had been implemented in Java on the server and again in JavaScript in the browser, so a change to a page’s behaviour had to be written, tested and debugged twice, in two languages, by people working from the same intention.
Netflix reported, as its own measurements, that moving to Node and a shared JavaScript codebase reduced the start-up time of the website from sixty seconds to under one second, a figure that refers to the server application’s start-up in its deployment environment rather than to a visitor’s page load. The company also reported that using the same language and many of the same libraries on both sides let it build and test interface changes once. Netflix later extended the approach, describing in 2017 how Node services supported its experimentation platform, in which the interface presented to members is varied continuously to measure the effect of changes, and how the ability to run the same code in the browser and on the server allowed a test to be evaluated in either place. Netflix’s streaming itself does not run on Node. The video is delivered by its own content delivery network, Open Connect, built for that purpose. Node’s role at Netflix is the interface and the services immediately behind it, which is a more useful fact than the broader claim sometimes made on its behalf, because it identifies the layer at which the runtime proved suitable for a service with, by the middle of the decade, more than seventy million members.
Uber and the dispatch problem
Uber’s use began with the problem at the centre of its business. Matching a rider requesting a car with a driver nearby, tracking both, recalculating as positions change and settling the trip afterwards is a continuous exchange of small messages between phones and servers, in which most connections are idle most of the time and a delay of seconds is visible to the customer. Uber built its dispatch system, the part of the platform that performs that matching, in Node, and its engineers described it as one of the company’s earliest and largest Node deployments.
Uber’s engineering publications from 2015 onwards describe two properties that decided the choice. The first was that Node’s asynchronous model fitted a system whose work consists of receiving a location update, consulting state and notifying a small number of other parties. The second was operational. A Node process that failed could be restarted quickly, and Uber built tooling to inspect and restart live processes with minimal interruption, which mattered in a system that could not be taken down for maintenance without stopping the business in the cities it served. Uber went on to build substantial open-source infrastructure around this work, including Ringpop, a library for consistent hashing and membership that lets a set of Node processes share state and route requests to the process holding a given item, and TChannel, a multiplexing request protocol. Both were written to solve problems Uber encountered at a scale its engineers put, in their own reporting, at millions of trips a day by 2015. The direction of that work is the point. Uber did not treat Node as a web tier in front of a system written elsewhere. It treated it as the system, and built the missing distributed-systems machinery around it.
NASA and the spacesuit data
The least commercial account is in some respects the most telling, because the requirement was safety rather than traffic. During a spacewalk outside the International Space Station on 16 July 2013, the astronaut Luca Parmitano reported water inside his helmet, and the walk was terminated early. The subsequent investigation required engineers to draw together data about the spacesuit, the Extravehicular Mobility Unit, from systems that NASA had accumulated over decades and that did not share a common structure.
The Node.js Foundation published a case study of the resulting project, in which NASA and its contractors built an end-to-end system in Node that brought the suit data into a single cloud-based database and exposed it through an application programming interface that engineers could query directly. NASA reported, in that case study, that the migration reduced the number of separate systems engineers had to consult and shortened the process of reaching a given piece of suit data from a sequence spread across multiple databases to a single query. The case is regularly summarised elsewhere with figures that NASA’s own published account does not support, and it is better cited for what it does establish. An agency with a conservative engineering culture, working on data relating to equipment on which lives depend, assessed the runtime and used it for the access layer of a safety investigation system. That is a different kind of evidence from a benchmark, and for many of the organisations that adopted Node after 2015 it was the kind that carried weight.
What the adopters gave back
Several of these organisations moved from using the runtime to maintaining parts of the ecosystem around it, which is a further form of evidence because it committed engineering time rather than opinion. PayPal released Kraken.js, the framework layer it had built on Express for its own applications. Walmart Labs released hapi and a series of related libraries, including the validation library joi, which went on to be used far outside retail. Uber released Ringpop and TChannel and published the operational tooling it had written for inspecting live Node processes. Netflix open-sourced Falcor, the data-fetching library it developed alongside its Node-based interface, in 2015. LinkedIn contributed to the Dust templating work it had used in its mobile stack and published its own findings on running Node under production load.
Companies also took formal positions in the project’s governance. When the Node.js Foundation was formed in June 2015 to receive the project from Joyent, its founding platinum members included IBM, Microsoft, PayPal, Fidelity and SAP, and its board drew on engineers from companies running Node in production. That structure was carried into the OpenJS Foundation in 2019. Corporate membership of a foundation is a modest commitment beside the cost of a migration, but it changed who was in the room when release schedules, long-term support periods and security policy were decided, and it meant that the requirements of large production users, including the long-term support cycle described in chapter sixteen, were represented by the organisations that had to plan around them.

12. Tooling testing and the developer facility
A runtime is used for a few hours a day. Its tooling is used for all of them. The programs that restart a server when a file changes, check code before it runs, format it so that a team’s files look alike, bundle it for the browser, report which line failed and measure how long a request took decide more of a developer’s working experience than any feature of the language itself. Node’s advantage in this area was not that it invented these tools. It was that a single package system, described in chapter six, made them installable in one command and disposable without consequence, so a developer could try a tool on a Tuesday and remove it on Wednesday at no cost beyond the time spent. Tooling that is cheap to try gets tried, and the tools that survived that process improved quickly.
Running and restarting
The most basic gap was that a Node server, unlike the page-based systems it replaced, was a long-running process that had to be started, watched and restarted. Editing a file had no effect until the process was stopped and started again, which during development meant an interruption every few seconds. Nodemon, created by Remy Sharp and released in 2010, closed that gap by watching the files in a project and restarting the process whenever one changed. It remains in routine use more than a decade later, which is a fair measure of how completely it solved a small problem. The equivalent need in production, keeping a process alive after a crash and restarting it without manual intervention, was met by process managers of which PM2, released in 2013 by Alexandre Strzelewski and developed through his company Keymetrics, became the most widely used. PM2 starts several copies of an application across the available processor cores, restarts any that fail, manages their logs and reports their memory and processor use. Node itself supplies the underlying capability through its cluster module, stable from the early releases, which lets a primary process distribute incoming connections among worker processes. PM2’s contribution was to make that capability a configuration file rather than a program.
Debugging followed a similar path from improvised to standard. Node inherited V8’s debugger, and for several years the practical route to inspecting a running process was a separate tool, node-inspector, created by Danny Coates, which connected a Node process to the browser’s developer tools. In July 2016 Node 6.3 shipped with the Inspector protocol built in, exposed through the --inspect flag. From that release a developer could start a server, open Chrome’s developer tools, set breakpoints in the source, step through asynchronous code and inspect the state of a request in progress, using the same interface already familiar from debugging the browser half of the same application. The significance is in that last point. One debugger, one set of keyboard shortcuts and one mental model served both halves of a system, and a fault that crossed the boundary between them could be followed across it.
Checking and formatting code
JavaScript’s flexibility makes errors cheap to write and, in a language without a compile step, sometimes expensive to find. The checking tools that Node developers adopted came in a line of descent. JSLint, written by Douglas Crockford in 2002, applied a strict personal standard and reported code that departed from it. JSHint, forked in 2010, made the rules configurable so that a team rather than an individual set the standard. ESLint, created by Nicholas C. Zakas and released in June 2013, made the rules themselves pluggable, so that any check could be added as a package, shared through npm and enforced identically on every machine in a team and on the server that runs the tests. ESLint became the standard linter for JavaScript, was adopted by the major frameworks as their default and was substantially rewritten in its version 9 release in April 2024 around a simpler configuration format, after a decade in which its original configuration system had become one of the most common sources of friction in setting up a project.
Formatting was settled by removing the decision. Prettier, created by James Long and released in January 2017, reformats code according to its own rules with very few options, wrapping lines, standardising quotation and indentation and rewriting the file in a canonical form. Its premise was that the time teams spent discussing style, in reviews and in configuration, was worth more than any particular style. Because Prettier is deterministic, it also made automated checking trivial. A project either matches the formatter’s output or it does not, and the disagreement ends there. Editors integrated it so that a file is formatted on saving, and the category of review comment concerned with spacing largely disappeared from projects that adopted it.
Transpilers and bundlers
Two further tools existed because JavaScript changes faster than browsers do, and both became part of the standard Node workflow. Babel, written by Sebastian McKenzie and released in September 2014 under the name 6to5, translates JavaScript written to a recent version of the language into an older version that current browsers can run. It was renamed Babel in February 2015 and became the means by which developers used new syntax, including the class and module features of the 2015 edition of the language, years before those features were available everywhere. Its plug-in architecture divided translation into individual transforms that could be combined as needed, and for a period in the late 2010s almost every JavaScript project of any size had a Babel configuration at its root.
Bundlers solved the corresponding problem of number. A browser application composed of hundreds of modules cannot sensibly request each one separately. Browserify, created by James Halliday and released in 2011, applied the Node module system to the browser, following an application’s require calls and producing a single file. Webpack, created by Tobias Koppers with its first release in February 2012, generalised the idea. Webpack treats every asset a project uses, JavaScript, stylesheets, images and fonts, as a module in one dependency graph, applies loaders that transform each type and emits optimised bundles, splitting the output so that a visitor downloads only the code for the page being viewed. Webpack’s configuration was notoriously demanding, and the frameworks of chapter ten eventually absorbed it, but for most of a decade it was the mechanism by which the modular code developers wrote became the handful of files a browser received. Later bundlers worked on speed. Esbuild, written in Go by Evan Wallace and released in 2020, performed the same tasks one to two orders of magnitude faster in its author’s reported benchmarks, and Vite, created by Evan You and released in 2020, used esbuild during development to serve modules to the browser on demand rather than bundling them in advance, which removed the wait at start-up that large Webpack projects had made routine. Rollup, from 2015, took the library author’s side of the same problem, producing small, clean bundles from the standard module format.
TypeScript and the typed layer
The largest addition to the tooling landscape came from outside the Node project. TypeScript, released by Microsoft in October 2012 and developed under Anders Hejlsberg, who had previously led the design of C#, adds static types to JavaScript and compiles to ordinary JavaScript that Node or a browser then runs. Types are checked before the program runs, so a class of error that JavaScript would otherwise report only when the faulty line executed, or not at all, is reported in the editor as the code is written. Editors use the same information to offer accurate completion, renaming and navigation across a large codebase.
Adoption was gradual and then general. Angular adopted TypeScript as its language in 2016, the frameworks and libraries that followed offered typed definitions as a matter of course, and npm began carrying type definitions for packages whose authors had written plain JavaScript, maintained through the community DefinitelyTyped repository. The cost is a build step and a second language to learn.[16] The benefit, reported consistently by large teams, is that refactoring a codebase of hundreds of thousands of lines becomes a checked operation rather than a search for consequences. Node itself moved towards the typed workflow in 2024, when version 22.6 added an experimental flag to strip type annotations and run TypeScript files directly, without a separate compilation step, for the common case in which types are used as annotations rather than as features requiring transformation. The flag’s existence is an acknowledgement of how completely the practice had settled. The runtime was adapting to the tooling its developers had chosen.
Testing
Testing in Node passed through the same consolidation. The earliest widely used framework was Mocha, created by TJ Holowaychuk and released in December 2011, which runs test files, reports results and leaves the choice of assertion library open, a role usually filled by Chai, released the same year. Mocha’s flexibility made it the default for libraries and server code, and it is still maintained and widely used. Jest, developed at Facebook and open-sourced in 2014, took the opposite position for application code. It bundled the test runner, assertions, mocking and coverage measurement in one package with a configuration that could be empty, ran tests in parallel in separate processes and introduced snapshot testing, in which a component’s output is stored and any change to it is presented for approval. Jest’s rewrite in 2016 made it practical at scale, and it became the default for React applications and, by extension, for much of the front-end work of the following years.
Vitest, announced in 2021 and reaching a stable release in 2023, reused Vite’s transformation pipeline so that tests run against the same configuration as the application itself, and adopted an interface compatible with Jest’s so that existing test suites could be moved with little rewriting. Node then closed the remaining gap from the other direction. Version 18, released in April 2022, included a built-in test runner, node:test, as an experimental feature, allowing a project to write and run tests with assertions from the standard library and no package to install at all. Its arrival does not displace the established frameworks, which offer more, but it sets a floor. A developer with nothing but the runtime can now test, debug, lint nothing yet still run, and ship a service, which was not true in 2010.
Alongside these sit the tools that connect a project to the rest of a team’s work. Package managers multiplied rather than consolidating. Yarn, released by Facebook in October 2016, introduced a lockfile and deterministic installation to npm-based projects at a time when npm’s own installations could differ between machines, and npm adopted both ideas in its version 5 release in May 2017. Pnpm, created by Zoltan Kochan in 2016, reduced disk use by storing each package once and linking it into projects rather than copying it. Corepack, included with Node from version 16.9 in September 2021, manages the choice between them from within the project. Visual Studio Code, released by Microsoft in April 2015 and built on Electron, the framework for desktop applications built with Node and Chromium that GitHub had released in 2013, became the most used code editor in developer surveys within a few years, and its debugging, terminal and extension system were designed around the Node workflow from the start. The editor in which most Node code is written is itself, in part, a Node application, which is as compact a statement as any of how far the tooling carried the runtime.
13. From callbacks to promises and async await
Every asynchronous operation in the first versions of Node.js was expressed in the same way. A function that read a file, queried a database or waited for a network response took one extra argument, a callback, and called that argument when the work was done. The convention that grew up around the pattern in 2010 and 2011, and that the core library then followed throughout, placed an error in the first position. The callback received an error object or null, followed by the result if there was one. A programmer checking a read therefore wrote a test for failure before any code that used the data, on every call, without exception. The pattern was simple, it mapped directly onto the event loop described in chapter five, and for short programs it was entirely adequate. A script that read one configuration file, opened one connection and printed one result could be followed from top to bottom by anyone who understood that the callback ran later, after the surrounding synchronous code had finished.
The difficulty appeared with sequence. Real server work is rarely one operation. A request handler might need to authenticate a user, then read that user’s record, then read the orders attached to the record, then read the stock position for each order, then write a response, handling a possible failure at each stage separately. Because each step could only begin inside the callback of the previous step, the code nested. Each level indented the next, so that a handler of six or seven dependent operations drifted steadily towards the right-hand margin, closed by a staircase of brackets and error tests at the bottom. Programmers named the shape plainly. It was called callback hell, or the pyramid of doom, and by 2012 it was the most common complaint made about Node programming in conference talks and on mailing lists. The complaint was not really about indentation, which a tidy programmer could manage. It was about reasoning. An error thrown inside a deeply nested callback could not be caught by a try and catch block written around the outer call, because the outer call had long since returned. Every stage therefore carried its own error branch, and a failure path that ought to have been written once was written six times, with six opportunities to forget it.
Forgetting had a particular consequence in early Node. If a callback was never called, nothing failed visibly. The operation simply never completed, the request hung, and the process carried on serving other work as though nothing were wrong. If a callback was called twice, through a fault in a library, downstream work ran twice. Neither error produced the stack trace that a synchronous exception produced, because there was no single stack connecting the place where work was requested to the place where it completed. Debugging tools of the period showed the current event, not the chain of intentions that had led to it. Developers learned defensive habits that now read as period detail. They wrapped callbacks so that a second invocation was ignored. They named callback functions instead of writing them inline, flattening the pyramid into a list of separate definitions that called one another by name, at the cost of scattering one logical operation across a whole file.
Control flow libraries and the first repairs
The first repairs came from the community rather than from the language. A library called async, written by Caolan McMahon and first released in 2010, collected the patterns programmers were writing by hand. It offered functions such as series, parallel and waterfall, which took an array of callback-style tasks and a final callback, ran the tasks in the stated relationship, gathered their results into one place and delivered any error once, to that final callback. A waterfall passed the result of each task to the next, which removed most of the nesting from dependent sequences. The library became one of the most downloaded packages on npm, and for several years a large share of production Node code depended on it, directly or through other packages that depended on it in turn. Its importance is easy to miss now that the language has absorbed its purpose. Async demonstrated that the problem was composition, not asynchrony itself. Programmers did not want to return to blocking calls. They wanted a way to describe a sequence of non-blocking calls as a sequence, in the order in which it would happen, with errors handled in one place.
Promises before they were native
The promise was older than Node. The idea of an object representing a value that would become available later, to which interested parties could attach handlers, had been described in programming language research in the 1970s and 1980s, and it had circulated in JavaScript libraries for years before it entered the language. A proposal known as Promises/A was discussed in the CommonJS community in 2009, the same year Node appeared. Libraries implemented and refined it. Q, by Kris Kowal, was influential in the early 2010s and introduced many programmers to chaining, in which each handler returns a new promise and the next handler attaches to that promise rather than nesting inside the previous one. When.js and RSVP offered other implementations. Bluebird, released in 2013 by Petka Antonov, concentrated on speed and on debugging aids, including longer stack traces that attempted to reconnect an error to the chain of operations that had produced it. Bluebird also provided promisify, a utility that converted a callback-style function following the error-first convention into a function returning a promise, which allowed old and new code to be mixed in one codebase during a migration.
What these libraries shared, beneath differences of performance and extra features, was a single model. A promise is in one of three states. It is pending, then it settles, either fulfilled with a value or rejected with a reason, and once settled it does not change. Handlers attached with the then method are called on fulfilment, handlers attached with catch are called on rejection, and attaching a handler to an already settled promise still works, the handler being called asynchronously with the settled result. That last property removed a whole class of timing fault from callback code. With callbacks, a function that sometimes completed synchronously and sometimes asynchronously was dangerous, because the caller could not predict whether surrounding code had run. With promises, handlers were guaranteed to run after the current synchronous execution, on what the specification calls the microtask queue, a queue of jobs processed between the completion of one piece of script and the next task from the event loop. The guarantee was small and absolute, and a great deal of reliability followed from it.
Chaining, composition and the handling of errors
Chaining changed the shape of the code described at the start of this chapter. The sequence of authentication, record, orders and stock could be written as a series of then calls at one level of indentation, each receiving the previous result. An error at any stage skipped the remaining fulfilment handlers and arrived at a single catch at the end of the chain, which restored the property synchronous programmers took for granted, that one failure path could serve a whole operation. Promise.all took an array or other iterable of promises and fulfilled with an array of their results once all of them had fulfilled, or rejected as soon as any one rejected, which expressed parallel work directly. Promise.race settled with the first input to settle, a pattern used for timeouts, in which an operation races a promise that rejects after a stated interval. Later additions filled gaps that production use exposed. Promise.allSettled, standardised in ECMAScript 2020 and available in Node 12.9.0 and later, waited for every input and reported each outcome, fulfilled or rejected, which suited batch work where one failure should not discard successful results. Promise.any, standardised in ECMAScript 2021, fulfilled with the first fulfilment and rejected only if every input rejected, the natural expression of asking several mirrors for the same file and taking whichever answered first.
Node’s own library moved more slowly than the language, deliberately. Core modules kept their callback interfaces for years after promises became native, because changing the interface of the file system or the network modules would have broken a very large body of existing code. The bridge was provided in stages. The util.promisify function, added in Node 8.0.0 in May 2017, converted any error-first callback function into a promise-returning function by convention, with special handling for core functions whose callback shapes did not fit the convention exactly. Dedicated promise interfaces followed. The fs/promises module, providing promise-based versions of the file system functions, appeared experimentally in Node 10.0.0, was available through require of fs with a promises property, and reached stability in Node 14.0.0. The timers/promises module in Node 15.0.0 provided promise versions of setTimeout and setInterval, so that waiting for an interval became an awaitable operation rather than a callback or a hand-built promise. The dns/promises module followed the same pattern. By the early 2020s a new Node program could be written entirely against promise-based core interfaces, while a program from 2013 using callbacks in the same modules would still run, which is the practical meaning of the stability commitments described in chapter sixteen.
Async and await
The final step in this sequence came from the language again. Proposals for asynchronous functions had circulated through the ECMAScript standards committee, drawing on the async and await syntax that Microsoft had introduced in C# in 2012. ECMAScript 2017, published in June 2017, standardised the form for JavaScript. A function declared with the async keyword returns a promise. Inside it, the await keyword pauses the function at a promise, without blocking the thread or the event loop, and resumes it with the fulfilled value when that promise settles, or throws the rejection reason at that point, where an ordinary try and catch block can catch it. Node 7.6.0, released in February 2017, shipped a V8 version that enabled asynchronous functions without a command-line flag, ahead of the formal publication of that year’s standard, and Node 8.0.0 carried them into a long-term support line three months later.
The effect on ordinary code was larger than the small syntax change suggests. The authentication sequence that had once filled a screen with nested callbacks, and then a chain of then calls, could now be written as a list of statements in the order in which they happened, each assigning its result to a variable, with one try and catch around the whole. Loops worked as a programmer would expect. Awaiting inside a for loop performed the operations one after another. Conditional logic worked, because an awaited value was simply a value by the time the next line ran. Debugging improved for a structural reason. Because an asynchronous function is a single function whose execution the engine itself suspends and resumes, rather than a set of separate callbacks connected by a library, the engine could reconstruct its call stack across an await point. Node’s inspector and the debugging tools built on the Chrome DevTools protocol, integrated into Node from version 6.3.0 in 2016, developed asynchronous stack traces that showed that reconstructed chain, so that an error reported after several awaited operations named the operations that had led to it.
Async and await did not replace promises. They are promises, viewed from inside. An async function is a function returning a promise, an awaited value is unwrapped by the same thenable convention, and the composition methods of the previous section remained the right tools for work that was genuinely parallel. Awaiting a list of independent operations one at a time serialised them, discarding the concurrency the event loop offered, so Promise.all retained a daily use that no syntax removed. The mature style that settled in Node codebases by about 2020 used each form where it fitted. Sequential logic was written with async and await. Parallel work was gathered with Promise.all or Promise.allSettled. Library interfaces returned promises. Callbacks survived at the boundaries, in older modules, in event emitters, which are not promise-shaped at all because an event such as an incoming request or a chunk of streamed data happens repeatedly rather than settling once, and in performance-sensitive internal code where creating a promise for every small operation carried a measurable cost.
What the transition cost and what it settled
The transition took most of a decade and it was not free of error. Unhandled rejections were the sharpest problem. A rejected promise with no catch handler attached represented a failure that no code had seen. Early versions of Node printed a warning, UnhandledPromiseRejectionWarning, and allowed the process to continue, which meant a failed database write could pass unnoticed in a running server. The warning named a future in which the behaviour would change, and in Node 15.0.0, released in October 2020, it did. The default mode became throw, so that an unhandled rejection terminated the process as an uncaught exception did, on the reasoning that a process which had lost track of a failure was safer stopped and restarted by its supervisor than left running in an unknown state. The change broke programs that had accumulated silent rejections, deliberately, and the release notes said so. It is a clear example of a correction that could only be made at a major version boundary, under the release discipline described in chapter sixteen.
By the time Node 20 entered long-term support in October 2023, the question that had dominated discussion of Node programming in 2012 was no longer being asked. Nobody described ordinary Node code as callback hell, because ordinary Node code contained few callbacks. The sequence matters for understanding the platform’s facility, a word the outline of this post uses deliberately. Node did not become easier to write because its model changed. The event loop, the non-blocking interfaces and the single main thread are what they were in 2009. It became easier because three layers, community libraries, a cross-library specification and then the language standard, each absorbed the lessons of the layer before, and because the runtime kept the older interfaces working while the newer ones were adopted. That pattern, of experiment in packages, convergence in practice and eventual adoption into the platform, recurs in the subjects of the next chapter.
14. Microservices APIs and the headless web
An application programming interface, in the sense used in this chapter, is a contract between two pieces of software, a set of requests one may make of the other and of responses it may return, defined precisely enough that either side can be rewritten without the other changing. The old-style website described in chapter seven had no such contract at its centre. It had pages. A browser asked for a document and a server assembled the whole document, data, structure and presentation together, from its database, on each request. The arrangement was coherent while the browser was the only client. It became a constraint when it stopped being the only one, and the date at which that happened can be fixed quite closely. Apple opened the App Store in July 2008, and within a few years a service of any size expected to serve a website, an iPhone application, an Android application and often a partner’s system as well, all reading and writing the same underlying data. A server whose only output was finished HTML pages could serve exactly one of those four.
The response, across the industry and not only in Node, was to separate the data from its presentation and to put the API first. The server would expose endpoints, addresses at which a client could request a defined resource, and return the data in a structured format, most often JSON, the JavaScript Object Notation described in chapter eight. Each client then rendered that data in its own way. The website became one client among several, frequently a JavaScript application running in the browser and calling the same API that the mobile applications called. This is the architecture that Node entered in 2009 and for which its properties were well matched. An API endpoint typically does little computation. It receives a request, validates it, makes one or more calls to a database or to other services, assembles a modest body of JSON and returns it. That is input and output work of exactly the kind the event loop handles in large numbers on one thread, and the data format at its centre is the native notation of the language the server is written in.
REST and the shape of an endpoint
The dominant style for these interfaces in the 2010s was REST, representational state transfer, a term from Roy Fielding’s doctoral dissertation of 2000 at the University of California, Irvine, describing the architectural principles of the web itself.[17] In its practical form, as most teams applied it, REST meant that resources were named by nouns in the address, that the standard methods of the Hypertext Transfer Protocol carried their ordinary meanings, so that GET read, POST created, PUT or PATCH updated and DELETE removed, and that each request carried everything the server needed to answer it, without the server remembering a conversation between requests. A request to GET /orders/4821 returned a representation of that order. The same address with DELETE removed it. The discipline was conventional rather than enforced, and teams argued about its finer points for years, but its practical achievement was a shared expectation. A developer who had never seen a particular API could predict most of its addresses and methods before reading its documentation.
Dividing the monolith
The monolith is the name later given, usually by its critics, to a server built as one program containing every function of a service, accounts, catalogue, orders, payments, search and reporting in a single codebase deployed as a single unit. The form has real virtues. Its parts call one another directly, a transaction can span them, and there is one thing to deploy and to watch. Its weaknesses grow with the team rather than with the traffic. A change to payments requires redeploying the catalogue. A fault in reporting can exhaust the memory available to checkout. Fifty developers committing to one codebase spend an increasing share of their time coordinating releases rather than writing code. Microservices were the proposed answer, a term that gained currency after a gathering of architects in Venice in 2011 used the word microservice, and that was set out in a widely read article of March 2014 by James Lewis and Martin Fowler.[18] The proposal was to divide the one program into many small services, each responsible for one bounded area of the business, each owning its own data, each deployed independently, communicating with the others over the network through APIs of the kind described above.
Node fitted this division for reasons that were partly technical and partly economic. A microservice is by definition small, and a runtime with a small footprint and a fast start suits it. The base Node process uses considerably less memory than a traditional application server carrying a thread pool and a large standard library, so running forty small services on the same hardware as one large one was a practical proposition rather than an extravagance. A service written in Node could be owned by the team that also wrote the web front end calling it, since both were JavaScript, which removed the hand-off between a front-end team and a back-end team that had structured many organisations. The package system helped as well. Shared concerns such as authentication, logging and request validation could be published as internal packages and versioned, so that a correction could be adopted service by service instead of in one coordinated change.
The honest account of microservices, which the engineering literature of the late 2010s supplies in quantity, is that the division moved complexity rather than removing it. A function call that could not fail became a network call that could fail in several ways, slowly, partially or after succeeding on the far side while its response was lost. Teams acquired new obligations that a monolith had never imposed. They needed service discovery, a means by which one service found the current addresses of another as instances were started and stopped. They needed load balancing between those instances, retries that did not multiply a failing request into a storm, and circuit breakers that stopped calling a service known to be down. They needed distributed tracing, following one user request as it passed through six services, because a log file on one machine no longer contained the story of anything. They needed contracts tested between services, since the compiler no longer checked that a caller and a callee agreed. Organisations that adopted the style for its fashion rather than for a coordination problem they actually had were a recognised failure mode by about 2018, and the term monolith-first, Fowler’s own advice to begin with one program and divide it only where a boundary proved necessary, entered the vocabulary as the correction.
Gateways, back ends for front ends and GraphQL
As the number of services grew, a further layer appeared between clients and services. An API gateway is a single entry point that receives every external request, authenticates it, limits its rate, routes it to the appropriate internal service and returns the response. It gives an organisation one place to apply the rules that apply to everything. A refinement of the pattern, described by Sam Newman and associated with SoundCloud’s experience, was named back end for front end. Instead of one gateway shaping every response for every client, each kind of client had its own thin server, one for the web, one for the mobile application, which called the internal services and assembled exactly the data that client needed, in the shape that client needed it. The pattern suited Node particularly well and Node was frequently chosen for it, because these aggregation servers were written by the same front-end teams whose clients they served, in the same language, and because their work was almost entirely the concurrent calling of other services and the reshaping of JSON, the two operations at which the platform was most practised. PayPal and Netflix both published accounts in the 2010s of Node performing this aggregation role in their own architectures, accounts discussed with their figures in chapter eleven.
A different answer to the same pressure arrived from Facebook. A mobile application screen typically needs data from several resources at once, a user, their recent posts, the comments on each, and under REST that meant several requests and often more data in each response than the screen used, because an endpoint shaped for all clients could not be shaped for one screen. Facebook built GraphQL internally from 2012, released a public specification and a reference implementation in 2015, and transferred the project to the GraphQL Foundation under the Linux Foundation in 2018. GraphQL is a query language for APIs. The client sends one request describing the fields it wants, in a nested structure matching the shape of the answer it needs, and the server returns JSON in exactly that shape. Apollo, a company building GraphQL tooling, released Apollo Server for Node, and the Express integration alongside it, making a GraphQL endpoint a routine addition to a Node service. GraphQL did not displace REST, which remains the more common style for public and partner APIs, where its address-based model fits caching by content delivery networks and the expectations of outside developers. The two settled into different work, REST at the boundary between organisations, GraphQL frequently at the boundary between a company’s own clients and its services, with Node commonly on the server side of both.
The headless web
Headless, in web publishing, means that a system which once produced pages now produces only content through an API, leaving the presentation to whatever asks for it. A headless content management system stores articles, images and structure as a traditional system does, and its administrative interface for editors may be unchanged, but it has no public website of its own. A separate front end, often a Node application, calls its API, receives the content as JSON and builds the pages. The word is borrowed from the older computing sense of a machine run without a display. WordPress, originally a page-producing system of 2003, added a REST API to its core in version 4.7 in December 2016, which made the most installed publishing system in the world usable as a headless source. Companies founded specifically on the model, among them Contentful, founded in Berlin in 2013, and Sanity and Strapi in the years that followed, supplied the content side as a service, with Strapi itself written in Node.
15. Competition and correction — Deno Bun and returning to Node
On 29 May 2018, at JSConf EU in Berlin, Ryan Dahl gave a talk with a title that guaranteed an audience, “10 Things I Regret About Node.js”. The venue and the format were deliberate echoes. Nine years earlier, in the same conference series in the same city, he had introduced Node itself. Now he listed its faults as he saw them, in the order of a man reading out charges against his own work. The build system for native modules, written in Python under the name GYP, he called a burden. The package.json file had accumulated fields he considered unnecessary, and the centralised registry it pointed to had become a single point of dependence for the whole ecosystem. The index.js convention, by which a directory could stand for a module, he described as needlessly complicated. Above all he regretted the security model, or its absence. A Node program, and therefore every package it installed, ran with the full permissions of the user who started it. Any dependency could read files, open network connections and run other programs, and the ecosystem described in chapter six rested on the assumption that thousands of packages, maintained by strangers, would not do so maliciously.
The talk did not end with the list. Its second half introduced a prototype called Deno, an anagram of Node, a new runtime for JavaScript and TypeScript that Dahl had been building to test whether those decisions could be made differently a second time. The episode matters to a history of Node for two reasons. It is the clearest public statement, by the person best placed to make it, of where the platform’s weaknesses actually lay, as opposed to where its critics guessed they lay. And the response of the platform over the following six years, absorbing some of the corrections, declining others and outlasting the challenger in deployment, is the best available evidence about how an established runtime changes. It changes slowly, at its boundaries, and largely by addition.
Deno and the permissions argument
Deno 1.0 was released on 13 May 2020. Its differences from Node were architectural statements, each answering an item on the 2018 list. Permissions were explicit and denied by default. A Deno program could not read the file system, reach the network or inspect its environment unless the person running it granted that capability with a flag such as –allow-read or –allow-net, so that a command stated, in its own text, what the program was permitted to do. TypeScript was supported without a separate compilation step, the runtime performing the type removal itself. There was no package.json and no node_modules directory. Modules were imported by address, most often a URL, and cached by the runtime, on the argument that the web itself was the distribution system and a central registry was a liability. A single executable contained the runtime together with a standard library, a formatter, a linter and a test runner, tools that Node left to packages. The binary was written in Rust, the systems language that had become the usual choice for new infrastructure in the late 2010s, around the same V8 engine that Node used.
The design was coherent and the criticism behind it was largely accepted as fair, including by people who stayed with Node. What Deno asked of its users, however, was not a correction but a migration. Existing Node programs did not run unchanged. The vast library of npm packages, the asset that chapter six identified as Node’s deepest advantage, was written against Node’s module system and Node’s built-in interfaces, and Deno programs could not use most of it directly. A company with a working Node service was being asked to rewrite it, re-staff its maintenance and re-learn its failure modes, in exchange for a permissions model and a tidier module system. Most companies, presented with that exchange in 2020, declined it. Deno found its users in new projects, in scripting and in teams for whom the security model was the deciding requirement, and its company, Deno Land Inc, founded in 2021, built a hosting service, Deno Deploy, around it. The runtime’s own subsequent history records the strength of the opposing pull. Deno 1.28, in November 2022, added substantial support for npm packages. Deno 2.0, released on 9 October 2024, made that compatibility a central feature, with support for package.json, node_modules and the Node built-in modules, presenting itself no longer as a replacement world but as a runtime in which the existing world could also run. The direction of travel had reversed. The challenger had moved towards the incumbent’s ecosystem, because the ecosystem was where the users were.
Bun and the performance argument
The second challenger argued about speed rather than design. Bun was created by Jarred Sumner and first released in a public beta on 7 July 2022, with version 1.0 following on 8 September 2023. It is a JavaScript runtime written in Zig, a low-level language, built not on V8 but on JavaScriptCore, the engine developed by Apple for Safari. Its claims were comparative and specific. It started programs faster than Node, it ran a built-in test runner, bundler and package manager that its authors measured as many times faster than the Node equivalents, and it installed packages from npm at a speed that made the standard installer look slow in direct comparison. Those installation figures were the project’s own published measurements and should be read as such. Bun also took the opposite strategic decision to early Deno. Compatibility with Node was the goal from the beginning. Bun aimed to run existing Node programs, to implement the Node built-in modules and to serve as what its documentation called a drop-in replacement, so that adopting it required changing a command rather than a codebase.
What Node took from its critics
The more interesting half of this history is what changed inside Node itself during the same years, because several of the 2018 regrets were answered there. The permissions criticism was answered directly. Node 20.0.0, released in April 2023, introduced an experimental permission model under the flag –experimental-permission, with separate grants for reading and writing files and for running child processes, extended in later releases to network access. It was modelled on the same principle as Deno’s flags, that a process should be started with only the capabilities its work requires, and it arrived as an option rather than a new default, so that existing programs were not broken by it. The tools criticism was answered by absorption. A test runner, node:test, was added in Node 18.0.0 in 2022 and marked stable in Node 20.0.0, giving the platform a built-in way to write and run tests with no package to install. A –watch mode for restarting a program when its files changed, a facility developers had used the nodemon package for since the early 2010s, was added experimentally in Node 18.11.0 and stabilised in Node 22.0.0. An official facility for loading environment variables from a .env file, work that the dotenv package had performed in a very large number of projects, arrived in Node 20.6.0. A single-file executable facility, and a built-in WebSocket client, followed the same pattern.
The module criticism was answered more slowly, because it was the hardest to answer without breaking the installed base. Node had supported two module systems since 2019, the original CommonJS system with require, and the standard ECMAScript module system with import, which the language specification had defined and browsers used. Their interaction produced the most persistent friction in everyday Node work of the early 2020s, packages that could be imported but not required, configuration that differed between the two, and errors whose wording became familiar to every working developer. Node 22.0.0, in April 2024, enabled require of certain ECMAScript modules by default, modules without top-level await, closing much of the gap from the CommonJS side. The episode is worth recording because it shows the actual constraint on the platform’s development. The obstacle was rarely knowing what the better design was. Dahl’s 2018 list was not disputed on its merits by the people maintaining Node. The obstacle was that several million existing programs embodied the older design, and a correction that invalidated them would have been a new platform under an old name, which is precisely what Deno had offered and what most users had declined.
TypeScript followed the absorption pattern furthest. Dahl had listed its absence from Node’s original design, Deno had made it a founding feature, and through the early 2020s Node developers who used TypeScript, a large and growing share of them, compiled it to JavaScript first with the TypeScript compiler or with faster tools such as esbuild, written by Evan Wallace and released in 2020, or SWC, written in Rust. In July 2024 Node 22.6.0 added an experimental flag, –experimental-strip-types, which removed type annotations and ran TypeScript files directly, for the subset of the language whose types could be erased without changing the code’s meaning. Chapter sixteen returns to that development, because it belongs to the platform’s present state rather than to its controversies. Its place in this chapter is as the last of the corrections. Each of the three challenges of 2018 to 2022, permissions, bundled tooling and TypeScript, ended in the same way. The challenger demonstrated the feature, the demonstration persuaded the incumbent’s maintainers and users, and the feature appeared in Node, later, more cautiously, and in a form that existing programs could ignore. Programmers who had left for a challenger sometimes returned for exactly that reason, and the phrase returning to Node in this chapter’s heading describes a documented pattern of the period rather than a verdict on the challengers, whose work is the reason the corrections exist.
16. The foundation for what comes next
A foundation is judged by what can be built on it without asking its permission. The previous chapters described a runtime assembled in 2009 from a browser engine and a set of non-blocking interfaces, which became, over fifteen years, the layer on which a large part of the web’s server side, its build tooling and its client tooling all run. This chapter describes the state of that layer in the middle of the 2020s, and the specific properties, governance, release discipline, standard interfaces and points of contact with newer technologies, that determine what can next be built on it. It makes no predictions. Where a development is experimental, or a standard is still being written, it says so, because the distinction between what Node does today and what its maintainers propose is itself one of the platform’s working properties.
Governance and the OpenJS Foundation
Node is not owned by a company.[19] That is a legal fact with practical consequences, and it was arrived at through the fork and reconciliation described in earlier chapters. The Node.js Foundation was formed in 2015 as a project of the Linux Foundation, bringing the io.js fork and the original project back together under a governance model in which a Technical Steering Committee, drawn from the project’s contributors, directs the technical work, and no single employer controls the roadmap. In March 2019 that foundation merged with the JS Foundation, which supported jQuery and other long-lived JavaScript projects, to form the OpenJS Foundation, and Node has been an OpenJS project, at its highest impact grade, since then. The trademarks, the release infrastructure and the security process belong to that structure rather than to any firm that employs contributors, several of which, including companies whose products compete with one another, employ people who work on the same codebase.
Long-term support and the meaning of a version number
The release discipline is the other half of that answerability. Since the convergence of 2015, Node has released a major version every six months, in April and October. Even-numbered majors move, after six months as the Current release, into long-term support, abbreviated LTS.[20] An LTS release receives Active LTS maintenance for eighteen months and then Maintenance LTS for a further twelve, thirty months of support in total, during which it receives security fixes and corrections but not new features that might alter its behaviour. Odd-numbered majors never enter LTS and are supported only until the following June, existing to carry new work to early adopters. The lines current in the period of writing followed that pattern exactly. Node 20, released in April 2023, entered LTS in October 2023 under the code name Iron. Node 22, released in April 2024, entered LTS in October 2024 under the code name Jod. Node 24, released in May 2025, entered LTS in October 2025. The code names are alphabetical and chemical or material in theme, a small continuity the project has kept since Argon for Node 4.
The standard web platform arriving in Node
The largest technical change in Node between 2020 and 2025 was not a Node invention. It was the arrival, inside the server runtime, of the standard interfaces of the web platform, the same interfaces a browser provides. The fetch function, the standard way to make an HTTP request in a browser, was added experimentally in Node 18.0.0 in April 2022, implemented by the Undici library underneath it, and became stable and enabled by default in Node 21.0.0, with its underlying implementation carried into the LTS lines. Alongside it came the standard classes it depends on, Request, Response, Headers and FormData, the Web Streams interfaces ReadableStream and WritableStream, the Blob and File classes, the URL and URLSearchParams parsers that had arrived earlier, the Web Crypto interface for cryptographic operations, an implementation of WebSocket on the client side, stable in Node 22.0.0, and the Event, EventTarget and AbortController interfaces, the last of which gave Node a single standard way to cancel asynchronous work, from a fetch to a file operation, where each module had previously invented its own.
The significance is portability of knowledge and, increasingly, of code. A function written against fetch, Web Streams and Response runs in a browser, in Node, in Deno, in Bun and in the edge environments described below, because all of them implement the same specifications, maintained by the Web Hypertext Application Technology Working Group and Ecma International rather than by any runtime. A working group formed in 2022 under the name WinterCG, the Web Interoperable Runtimes Community Group at the World Wide Web Consortium, and rechartered in 2025 as an Ecma International technical committee, TC55, exists specifically to define the common subset of those interfaces that non-browser runtimes should provide, with Node’s maintainers among its participants. Server JavaScript in 2015 meant Node’s interfaces, which existed nowhere else. Server JavaScript in 2025 increasingly means a standard core, with each runtime’s own facilities around it. That convergence lowers the cost of leaving any one runtime, Node included, and the Node project’s participation in it is a decision to compete on implementation and ecosystem rather than on locking in its users.
TypeScript as a first-class input
TypeScript, Microsoft’s extension of JavaScript with static types, released in 2012 and described in chapter fifteen, became during the early 2020s the form in which a large share of new server JavaScript was written, while remaining a language that no runtime executed directly. It had to be compiled, or transpiled, to ordinary JavaScript first. Node closed most of that gap in two steps. Node 22.6.0, in July 2024, added type stripping behind the flag –experimental-strip-types. Node 23.6.0, in January 2025, enabled type stripping by default, and the facility was carried into the Node 22 LTS line, so that a .ts file using erasable syntax only, types that can be removed without changing the program’s behaviour, runs with the node command and no build step and no additional package. Full TypeScript features that require code generation, such as enums in their original form and parameter properties, are not supported by stripping, and Node 23.7.0 and Node 22.13.0 added a separate –experimental-transform-types flag for files that use them. The distinction is documented and deliberate. For the common case, a developer can now write, run, test and debug a typed program in Node with nothing installed but Node, which removes a stage of tooling that every project previously had to assemble and maintain for itself, and which chapter twelve identified as a real cost of the platform’s facility.
Edge and serverless execution
Two ways of running server code changed where Node programs execute during the period covered by this post, and both need describing carefully because Node’s place in each is different. Serverless, in the sense established by Amazon Web Services with Lambda in November 2014, means that a provider runs individual functions in response to events, an HTTP request or a file arriving in storage, bills for the time they run and manages the machines entirely. Node was among the first runtimes Lambda offered, in 2015, and it has remained among the most used there and in the equivalent services of other providers, for reasons already established in this history, a small footprint and a fast start being worth money in a system billed by the millisecond and started on demand. Providers publish managed Node runtimes tracking the LTS lines, and a function written for one is ordinary Node code, with the platform’s interfaces, plus the provider’s event shapes at its edges.
Edge computing, in the web sense, means running code in a provider’s points of presence close to the user, in dozens or hundreds of cities, rather than in one of a few large regions, so that the distance a request travels is short. The environments that popularised it are not Node. Cloudflare Workers, launched in 2017, runs code in V8 isolates, many tenants separated inside one process by the engine’s own isolation mechanism, and provides web platform interfaces rather than Node’s. Vercel’s Edge Runtime and Deno Deploy are similar in kind. What happened between 2022 and 2025 was a convergence from both directions. Those environments added Node compatibility layers, Cloudflare’s under the name nodejs_compat, expanded substantially in 2024 and 2025 to cover a growing list of built-in modules, so that code and packages written for Node could run there. Node, for its part, adopted the standard web interfaces those environments are built on, as the previous section described. The result is not that Node runs everywhere. It is that the boundary between a Node program and an edge program has become a defined translation rather than a rewrite, and that a developer choosing where a given piece of work executes, in a region, at the edge or in a browser, is increasingly choosing a deployment rather than a language.
WebAssembly interop
WebAssembly, abbreviated Wasm, is a binary instruction format for a stack-based virtual machine, standardised at the World Wide Web Consortium, which published it as a recommendation in December 2019, and supported by all major browsers as a compilation target for languages such as C, C++ and Rust. It matters to Node in two distinct ways. First, Node runs WebAssembly modules through V8, using the WebAssembly JavaScript interface, so that a performance-critical or pre-existing piece of code, an image codec, a parser, a cryptography library or a database engine, can be compiled once to Wasm and called from JavaScript in Node much as it would be in a browser. Packages took advantage of this to ship one binary artifact for both environments instead of maintaining native add-ons compiled separately for each operating system and processor, which had been a persistent source of installation failures in the npm ecosystem since its early years. SQLite compiled to WebAssembly, image libraries such as Sharp’s underlying components in Wasm form, and parsers for many formats reached users this way.
Artificial intelligence tooling and interfaces
The most recent body of work built on Node is the tooling around large language models, and it is best described by separating three layers that are often run together. At the lowest layer, Node is a client. The providers of these models, among them OpenAI, Anthropic and Google, publish official JavaScript and TypeScript libraries for their application programming interfaces, and those libraries run in Node, which makes a Node service the ordinary place from which a product calls a model, streams its response token by token to a browser over the streaming interfaces described in chapter nine, and combines the result with its own data. Streaming is not incidental here. A model’s answer arrives over tens of seconds, and a server whose purpose is to pass that stream onward while holding tens of thousands of such connections open is doing the work Node was designed for in 2009, applied to a source of data that did not then exist.
At the middle layer, Node is a framework host. LangChain.js, the JavaScript edition of the LangChain framework first released in 2022, and the Vercel AI SDK, released in 2023, provide the abstractions developers use to chain model calls, retrieve documents from vector databases and embed their text as numerical vectors for search, call external tools and structure a model’s output. Both are TypeScript projects distributed through npm. TensorFlow.js, released by Google in 2018, took the third layer, running models themselves, and provided a Node binding that used the TensorFlow C library for training and inference on a server, alongside its better-known browser form. The ONNX Runtime, Microsoft’s cross-platform inference engine, publishes a Node binding, onnxruntime-node, for running models in the Open Neural Network Exchange format locally. Local inference from JavaScript without a separate Python service became a practical option for smaller models through these bindings and through Wasm builds of inference engines, at speeds below those of dedicated graphics hardware, a limitation that belongs in any factual account.
At the newest layer, Node is a participant in a protocol. The Model Context Protocol, introduced by Anthropic in November 2024 as an open specification for connecting models to external tools and data sources, published official software development kits, and its TypeScript kit, maintained alongside the specification, is implemented for Node environments, so that a tool server exposing a database, a file system or a company’s internal service to a model is commonly a Node program. The pattern is the one this post has followed throughout. A new capability appears outside the platform, an interface is defined for it, and the place where that interface is implemented, for a very large number of working teams, is the runtime that is already installed, already understood and already connected to everything else they run. What is built on Node next will depend on decisions not yet taken by people who do not yet work on it. What can be said from the record is narrower and stronger. The governance is in place to maintain it, the release schedule is published years ahead, its interfaces are converging with the standards of the web itself, and it has absorbed, in succession, the module system, the asynchronous model, the type system and the deployment models that were each supposed to replace it.
Timeline
-
Brendan Eich creates the language at Netscape in May 1995, in about ten days. It ships as LiveScript in September and is renamed JavaScript in December 1995, running only inside the browser.
-
Google releases the Chrome browser on 2 September 2008 with V8, an open-source JavaScript engine led by Lars Bak that compiles JavaScript to machine code and makes browser applications markedly faster.
-
Ryan Dahl, working at Joyent, presents Node at JSConf EU in Berlin in November 2009, a server runtime built on V8 with an event loop and non-blocking input and output in place of threads.
-
Isaac Schlueter releases npm, the Node package manager, in 2010, and TJ Holowaychuk releases the Express web framework the same year. Installation and reuse of shared code become the ecosystem’s normal method.
-
Node 0.6, released in November 2011, adds native Windows support, developed with Microsoft, and the libuv library becomes the cross-platform layer beneath its asynchronous interfaces.
-
In January 2012 Dahl hands leadership of the project to Isaac Schlueter and moves to an advisory role, an early test of whether the project could outlast its founder’s direct control.
-
In December 2014 a group of core contributors forks Node as io.js, citing slow releases and Joyent’s governance, and ships its own releases through the first half of 2015.
-
The Node.js Foundation is formed under the Linux Foundation in 2015. Node 4.0.0, released in September 2015, reunites Node and io.js, brings native promises from ECMAScript 2015 and begins the long-term support schedule.
-
Vercel releases Next.js in October 2016, a React framework running on Node that renders pages on the server, extending Node’s role from API server to the machinery that builds and serves whole sites.
-
Node 8.0.0, released in May 2017, carries asynchronous functions from ECMAScript 2017 into a long-term support line, together with util.promisify for converting callback-style functions.
-
The Node.js Foundation and the JS Foundation merge in March 2019 to form the OpenJS Foundation. Node becomes its flagship impact project, governed independently of any single company.
-
Deno 1.0 is released in May 2020, two years after Dahl’s talk listing his regrets about Node. Node 15.0.0 follows in October 2020 and makes unhandled promise rejections terminate the process by default.
-
Node 18.0.0, in April 2022, adds the standard fetch interface experimentally and a built-in test runner. Bun, a rival runtime built on JavaScriptCore, reaches public beta in July 2022, arguing its case on speed.
-
Node 20.0.0, released in April 2023 and entering long-term support that October under the code name Iron, introduces an experimental permission model answering the security criticism made in 2018.
-
Node 22, released in April 2024 and entering long-term support in October as Jod, adds experimental TypeScript type stripping and require of suitable ECMAScript modules. Deno 2.0, in October 2024, centres compatibility with npm and Node.
-
Node 23.6.0 enables TypeScript type stripping by default in January 2025, and the facility is carried into the long-term support line. Node 24 is released in May 2025 and enters long-term support in October 2025.
Share this article
References
- Node.js project, “About Node.js”, Node.js. The project’s own description of the runtime, its event-driven model and its intended uses. *
- Garrett, Jesse James, “Ajax — A New Approach to Web Applications”, Adaptive Path, 18 February 2005, archived copy held by the Massachusetts Institute of Technology, MIT CSAIL. *
- JSConf EU, “JSConf.eu — 2009”, speaker programme including Ryan Dahl, “Node.js, Evented I/O for V8 Javascript”, Berlin, November 2009, JSConf EU. *
- V8 project, “V8 JavaScript engine”, V8. Google’s documentation for the engine, its just-in-time compilation and its release history. *
- libuv project, “libuv — Asynchronous I/O made simple”, libuv. Documentation for the cross-platform asynchronous input and output library used by Node.js. *
- Node.js project, “Node.js API Documentation”, Node.js. The reference documentation for the runtime’s modules, including timers, events and the event loop. *
- npm, Inc., “About npm”, npm Docs. The registry operator’s documentation for the package manager, the registry and package publication. *
- GitHub, “npm is joining GitHub”, The GitHub Blog, March 2020. GitHub’s announcement of its acquisition of npm, Inc. *
- Kegel, Dan, “The C10k problem”, kegel.com, first published 1999 and maintained by the author. The original statement of the problem of serving ten thousand simultaneous connections. *
- Crockford, Douglas, “The application/json Media Type for JavaScript Object Notation (JSON)”, RFC 4627, RFC Editor, July 2006. *
- Fette, Ian and Melnikov, Alexey, “The WebSocket Protocol”, RFC 6455, RFC Editor, December 2011. *
- Node.js project, “Stream — Node.js API Documentation”, Node.js. The documented stream interfaces, backpressure behaviour and pipeline methods. *
- Express project, “Express — Node.js web application framework”, Express. The framework’s official documentation for routing, middleware and application settings. *
- Vercel, “Next.js Documentation”, Next.js. The official documentation for server rendering, routing and deployment of the React framework. *
- LinkedIn, “LinkedIn Engineering Blog”, LinkedIn. The company’s engineering publication, including its accounts of moving its mobile and web services to Node.js. *
- Node.js project, “Introduction to Node.js”, Node.js Learn. The project’s introductory guide for developers new to the runtime. *
- Fielding, Roy Thomas, “Architectural Styles and the Design of Network-based Software Architectures”, doctoral dissertation, University of California, Irvine, 2000, University of California, Irvine. The dissertation that defined representational state transfer. *
- Lewis, James and Fowler, Martin, “Microservices”, martinfowler.com, 25 March 2014. A definition of the microservice architectural style and its trade-offs. *
- OpenJS Foundation, “OpenJS Foundation”, OpenJS Foundation. The foundation’s account of its projects, governance and the Node.js project’s place within it. *
- Node.js project, “Node.js Releases”, Node.js. The release schedule, long-term support lines and end-of-life dates maintained by the project. *
Select bibliography
- Node.js project, Node.js API Documentation, nodejs.org, continuously updated.
- libuv project, libuv Documentation, libuv.org, continuously updated.
- V8 project, V8 Documentation, v8.dev, continuously updated.
- npm, Inc., npm Documentation, docs.npmjs.com, continuously updated.
- Crockford, Douglas, JavaScript — The Good Parts, O’Reilly Media, 2008.
- Haverbeke, Marijn, Eloquent JavaScript, third edition, No Starch Press, 2018.
- Cantelon, Mike, Harter, Marc, Holowaychuk, TJ and Rajlich, Nathan, Node.js in Action, second edition, Manning Publications, 2017.
- Young, Alex and Harter, Marc, Node.js in Practice, Manning Publications, 2015.
- Powers, Shelley, Learning Node, second edition, O’Reilly Media, 2016.
- Fielding, Roy Thomas, Architectural Styles and the Design of Network-based Software Architectures, University of California, Irvine, 2000.
Related reading
The Clustering Effect
Why technology gathers into a few dozen places, what the gathering is worth in knowledge, labour and capital, what it costs in housing, inequality and fragility, and how the industry and its professional critics, Kara Swisher…
Why They Spend So Much
Five American technology companies now spend on artificial intelligence at the rate of industrial states, and almost none of it has yet produced a profit. This article follows the money: the circular deals between chip makers…
Nvidia and the AI Race
How one company's accelerators and CUDA software became the measure by which Washington and Beijing count AI strength - through the export controls that tried to fence off China, the smuggling prosecutions that followed, and the…