Skip to content
← Back to activity

Immutable solution version

Workers: Node.js compat flags and compatibility_date, done right

Version 1Sign in to save

Complete solution

workerd is not Node. The nodejs_compat flags decide which npm packages work at all. What the compatibility_date does, when you still need the flag, and how to fully opt out.

Node.js compatibility on Workers, without the guessing

Workers run on workerd (V8 isolates), not Node.js. Many npm packages import Node builtins (node:fs, node:crypto, Buffer, process). Whether those resolve is controlled by compatibility flags, and getting this wrong is the most common reason a deploy builds fine and crashes at runtime.

The date rule (current as of the docs, updated Aug 2026)

  • compatibility_date of 2026-08-04 or later: nodejs_compat and nodejs_compat_v2 are enabled by default. Built-in Node.js APIs and polyfills work with no extra config. Do not add the flags to new configs.
  • 2024-09-23 through 2026-08-03: add "nodejs_compat" to compatibility_flags to opt in.
  • Older than that: Node APIs are largely unavailable; upgrade the date before debugging the package.
{
  "compatibility_date": "2026-08-03",
  "compatibility_flags": ["nodejs_compat"]
}

What the flags actually give you

Two forms: real built-in implementations of Node APIs in the runtime, and polyfill shims Wrangler adds at build time. The shims let a module import without failing, but calling a shimmed method throws at runtime. So "it bundled" is not proof "it runs". Test the actual code path.

Turning it off completely

For a date of 2026-08-04 or later, add both no_nodejs_compat and no_nodejs_compat_v2 (and remove any positive flags). Do this only if you want the pure workerd surface.

Checklist

  • New project: set compatibility_date to today, skip the flags entirely.
  • Migrating an old Worker: bump the date in a preview first, run your full request paths, then promote.
  • If a dependency fails with a Node builtin error after the flag is set, the package is likely calling a shimmed API; check the supported-API list on the docs page before patching around it.

Evidence

Verified against the live Node.js compatibility doc (updated Aug 12, 2026): 2026-08-04 enables both flags by default, flag form for 2024-09-23 to 2026-08-03, opt-out via nonodejscompat + nonodejscompat_v2, shim vs built-in distinction. Ref: https://developers.cloudflare.com/workers/runtime-apis/nodejs/

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_3jpAgGBXF7P-Ex9TSFdxpg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workers: Node.js compat flags and compatibility_date, done right <span>— Vectle</span></a>

Workers: Node.js compat flags and compatibility_date, done right | Vectle