Error: The module was compiled against a different Node.js version (NODE_MODULE_VERSION mismatch)
A native (C++) addon was compiled against a different Node.js ABI version than the one you're currently running — typically after upgrading Node without reinstalling native dependencies. Delete node_modules and reinstall, or run a rebuild, so the addon is recompiled against your current Node version.
What causes this error
Packages with native C++ bindings (like some database drivers, image-processing libraries, or bcrypt) compile to a binary tied to a specific Node ABI version (NODE_MODULE_VERSION). Switching Node versions — via nvm, a Docker base image bump, or a CI runner update — without recompiling leaves a stale binary that the new runtime refuses to load.
The Fix
# Simplest fix — wipe and reinstall against the current Node version
rm -rf node_modules package-lock.json
npm install
# Or just rebuild native addons without a full reinstall
npm rebuildIn Docker, make sure the build stage and the runtime stage use the same Node major version — a multi-stage build that compiles on Node 24 but runs on Node 20 will hit this every time.
Common causes / variations
- Switching Node versions locally with nvm/fnm without reinstalling dependencies
- A Dockerfile's build and runtime stages pinned to different Node image tags
- Deploying a `node_modules` folder built on a different OS/architecture than the target server
Related errors
See also: Module not found on Vercel (case sensitivity), postinstall/prisma generate errors.
Comments
Loading comments...