Node.js 22

Error: The module was compiled against a different Node.js version using NODE_MODULE_VERSION

Error: The module was compiled against a different Node.js version using NODE_MODULE_VERSION

What it means

A precompiled native addon was built for a different Node.js ABI than the one now running.

Why it happens

Native Node addons (sharp, bcrypt, better-sqlite3, canvas, …) are tied to the Node major version's ABI (NODE_MODULE_VERSION). Upgrading the Lambda/container runtime to Node 22 without rebuilding or bumping these packages triggers the mismatch.

How to fix it

  1. Rebuild native modules against the new Node version: `rm -rf node_modules && npm install` (or `npm rebuild`).
  2. If the package has no Node 22 prebuild, upgrade it to a version that does (e.g. sharp >= 0.33.0, bcrypt >= 5.1.1, better-sqlite3 >= 11.0.0).
  3. For dead packages with no Node 22 build (node-sass, fibers, grpc), replace them (sass, native timers, @grpc/grpc-js).
  4. Build the deployment package on the same Node major version Lambda will run.

Related deadline: Lambda Node.js 20 Phase 12027-02-01.

Find every instance in your project

The free EOLkits scanner runs in your browser (nothing uploaded) and flags this and related breakages across your IaC and dependency files.

Primary source: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Get the full migration audit — $299, hash-anchored PDF →