NestJS 12 on AWS Lambda: the ESM crash and how to fix it

AWS Lambda disables require(esm) on Node.js 20, 22 and 24, so a CommonJS NestJS 12 app crashes with ERR_REQUIRE_ESM on startup.

In our lab the crash hit all five Node versions tested, from 20.19.0 to 24.15.0, so upgrading Node does not fix it.

An esbuild bundle and a move to ESM both booted under Lambda's flag; the NODE_OPTIONS fix depends on AWS runtime behavior we could not reproduce locally.

Read the full post

Read the full post