{"library":"node-abi","title":"Node.js and Electron ABI Utility","description":"node-abi is a utility library designed to retrieve and match Node.js and Electron Application Binary Interface (ABI) versions with their corresponding target versions and runtimes. It is critical for developers working with native Node.js modules that need to be compiled against specific Node.js or Electron environments, ensuring compatibility and preventing runtime errors due to ABI mismatches. The package maintains a comprehensive and frequently updated registry of ABI data. Currently, the stable version is 4.28.0, with a parallel 3.x branch (e.g., 3.89.0) also being actively maintained. Releases are frequent, typically occurring multiple times a month, primarily to incorporate the latest ABI changes from new Node.js and Electron releases. Its key differentiator is its consistent and up-to-date ABI registry, making it an indispensable tool for projects utilizing `node-gyp` or similar native module compilation processes, especially within the Electron ecosystem.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-abi"],"cli":null},"imports":["import { getAbi } from 'node-abi';","const { getTarget } = require('node-abi');","import { abiMap } from 'node-abi';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { getAbi, getTarget, getNodeVersion, getElectronVersion, abiMap } from 'node-abi';\n\n// Example 1: Get ABI for a specific Node.js target version\nconst nodeTargetVersion = '20.0.0';\nconst nodeAbiVersion = getAbi(nodeTargetVersion, 'node');\nconsole.log(`ABI for Node.js ${nodeTargetVersion}: ${nodeAbiVersion}`);\n\n// Example 2: Get target version for a specific ABI and runtime\nconst currentAbi = process.versions.modules; // ABI of the current Node.js runtime\nconst targetNodeVersion = getTarget(currentAbi, 'node');\nconsole.log(`Node.js version for ABI ${currentAbi}: ${targetNodeVersion}`);\n\n// Example 3: Check ABI for an Electron version\nconst electronTargetVersion = '28.0.0';\nconst electronAbiVersion = getAbi(electronTargetVersion, 'electron');\nconsole.log(`ABI for Electron ${electronTargetVersion}: ${electronAbiVersion}`);\n\n// Example 4: Access the raw ABI map\nconsole.log('Partial ABI map entry for Node.js 20:', abiMap.find(entry => entry.runtime === 'node' && entry.target === '20.0.0'));\n\n// Example 5: Get Node.js version from ABI\nconst someAbi = '115'; // Example ABI value for Node.js 20.x\nconst nodeVersionFromAbi = getNodeVersion(someAbi);\nconsole.log(`Node.js version for ABI ${someAbi}: ${nodeVersionFromAbi}`);\n\n// Example 6: Get Electron version from ABI\nconst someElectronAbi = '118'; // This is an example, actual ABI for Electron 28 may vary\nconst electronVersionFromAbi = getElectronVersion(someElectronAbi);\nconsole.log(`Electron version for ABI ${someElectronAbi}: ${electronVersionFromAbi}`);","lang":"typescript","description":"This quickstart demonstrates how to use `node-abi` to retrieve ABI versions for given Node.js and Electron target versions, find target versions from ABIs, and inspect the underlying ABI map, covering common use cases for native module compatibility.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}