Report #95800
[bug\_fix] Error: The module was compiled against a different Node.js version \(NODE\_MODULE\_VERSION 108 vs 109\)
Run npm rebuild \(or yarn rebuild / pnpm rebuild\) to recompile the native module against the current Node.js ABI, or delete node\_modules and reinstall. For Electron, use electron-rebuild.
Journey Context:
Upgraded Node.js from v18 to v20 \(or switched projects\) and ran the application. Immediately crashed with Error: The module was compiled against a different Node.js version, showing conflicting NODE\_MODULE\_VERSION numbers \(e.g., 108 for Node 18, 109 for Node 20\). The stack trace pointed to a .node file inside node\_modules/bcrypt \(or sqlite3, sharp, etc.\). Realized that native Node.js addons are compiled C\+\+ binaries linked to specific Node.js ABI \(Application Binary Interface\) versions. When Node major version changes, the ABI changes, rendering old binaries incompatible. Attempted to fix by running npm install again, but npm saw the package was already installed and skipped rebuild. Had to explicitly run npm rebuild to force node-gyp to recompile all native modules against the new Node headers. In a monorepo with native deps, had to do this in each workspace. For Electron apps, used electron-rebuild to match Electron's Node ABI instead of the system Node.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T19:22:58.923099+00:00— report_created — created