Registry / devops / node-abi

node-abi

JSON →
library4.28.0jsnpmunverified

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.

devops
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

node-abi provides named exports. Attempting a default import is incorrect. For CommonJS, use `const { getAbi } = require('node-abi');`.

import { getAbi } from 'node-abi';

This is the standard CommonJS named import. ESM users can use `import { getTarget } from 'node-abi';`. The package exports named functions, not a default export.

const { getTarget } = require('node-abi');

`abiMap` is a static array property containing ABI definitions, not a function. Do not call it.

import { abiMap } from 'node-abi';

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.

import { getAbi, getTarget, getNodeVersion, getElectronVersion, abiMap } from 'node-abi'; // Example 1: Get ABI for a specific Node.js target version const nodeTargetVersion = '20.0.0'; const nodeAbiVersion = getAbi(nodeTargetVersion, 'node'); console.log(`ABI for Node.js ${nodeTargetVersion}: ${nodeAbiVersion}`); // Example 2: Get target version for a specific ABI and runtime const currentAbi = process.versions.modules; // ABI of the current Node.js runtime const targetNodeVersion = getTarget(currentAbi, 'node'); console.log(`Node.js version for ABI ${currentAbi}: ${targetNodeVersion}`); // Example 3: Check ABI for an Electron version const electronTargetVersion = '28.0.0'; const electronAbiVersion = getAbi(electronTargetVersion, 'electron'); console.log(`ABI for Electron ${electronTargetVersion}: ${electronAbiVersion}`); // Example 4: Access the raw ABI map console.log('Partial ABI map entry for Node.js 20:', abiMap.find(entry => entry.runtime === 'node' && entry.target === '20.0.0')); // Example 5: Get Node.js version from ABI const someAbi = '115'; // Example ABI value for Node.js 20.x const nodeVersionFromAbi = getNodeVersion(someAbi); console.log(`Node.js version for ABI ${someAbi}: ${nodeVersionFromAbi}`); // Example 6: Get Electron version from ABI const someElectronAbi = '118'; // This is an example, actual ABI for Electron 28 may vary const electronVersionFromAbi = getElectronVersion(someElectronAbi); console.log(`Electron version for ABI ${someElectronAbi}: ${electronVersionFromAbi}`);
Debug
Known footguns
breakingVersion 4.0.0 of `node-abi` dropped support for older Node.js and Electron versions. Specifically, it requires Node.js >= 16 and Electron >= 11.
gotchaThe `node-abi` package often maintains multiple parallel major versions (e.g., v3.x and v4.x) simultaneously. Developers must ensure they install the correct major version compatible with their project's Node.js or Electron target version to get accurate ABI information.
gotchaThe ABI registry data within `node-abi` updates frequently with new Node.js and Electron releases. Relying on an outdated version of `node-abi` can lead to build failures or runtime ABI mismatch errors when compiling or loading native modules for newer environments.
gotchaWhen using `getAbi` or `getTarget`, it's crucial to specify the correct `runtime` ('node' or 'electron') to obtain accurate ABI information. Mismatched runtimes can lead to incorrect ABI lookups.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
gptbot
4
ahrefsbot
3
script
1
googlebot
1
oai-searchbot
1
Resources