Back to TIL
Today I Learned Quick knowledge bits

How to fix "Uncaught Error: No such module "node:buffer"."

· 1 min read
Updated:

The error doesn’t happen on the server, but during the deployment validation.

When Wrangler validates your Worker, it checks several critical aspects:

  1. Node.js module compatibility
  2. Worker size limits
  3. Runtime compatibility flags

It’s triggered by attempting to use Node.js-specific modules (node:buffer) in the Cloudflare Workers runtime.

To fix it, you only have to update your wrangler.toml:

compatibility_flags = ["nodejs_compat"]