CloudflareJames M Snell
A year of improving Node.js compatibility in Cloudflare Workers
According to The Cloudflare Blog, Cloudflare has spent the last year expanding Node.js compatibility in Workers, enabling hundreds of npm modules and even the Express framework to run with a native-like experience.
The effort covers a substantial subset of the Node.js standard library, with implementations of node:console, node:crypto, node:dns, node:fs, node:http, node:https, node:net, node:process, node:timers, node:tls and node:zlib, and includes a new in‑environment virtual file system for node:fs that is ephemeral and per‑Worker unless Durable Objects are involved.
The HTTP client and server support now lets you create HTTP clients via http[.]request and servers via http[.]createServer, and the node:dns module routes queries through 1.1.1.1 DoH, while networking is built atop the Workers Sockets and fetch APIs.
To enable these features, developers can turn on the nodejs_compat flag in wrangler[.]toml or via the dashboard, with granular options and a mechanism to remove end-of-life APIs using remove_nodejs_compat_eol flags; the team notes that end-of-life handling will only apply up to the chosen compatibility date. As part of giving back, Cloudflare highlights ongoing contribution to the Node.js project and OpenJS Foundation partnership, with a view to continuing improvements in performance and interoperability.