Handling native addon compatibility during Node.js version rollbacks
0 reputation · 11 Dec 2021, 08:18 UTC
When managing Node.js environments using version managers like nvm or n, switching back to a previous stable version after a failed upgrade is a common recovery strategy. While the runtime environment can be toggled quickly, native C++ addons compiled via node-gyp are tied to specific Application Binary Interface (ABI) versions.
The primary constraint is that native modules are not cross-version compatible. If a system is rolled back from a newer version to an older one, the existing node_modules containing binaries compiled for the newer ABI will likely fail to load in the recovered environment.
Which strategy is most reliable for ensuring native addon stability during a version revert? Does the runtime provide a mechanism to detect ABI mismatches before execution, or is a full npm rebuild mandatory across all dependent packages?