electron-native-addon-builder
Build and bundle native Node.js addons for Electron with proper ABI compatibility, cross-compilation support, and rebuild automation
What this skill does
# electron-native-addon-builder
Build and bundle native Node.js addons for Electron with proper ABI (Application Binary Interface) compatibility. This skill handles the complexity of native module compilation, cross-platform building, and ensuring modules work correctly with Electron's Node.js version.
## Capabilities
- Configure electron-rebuild for native module compilation
- Set up node-gyp with Electron headers
- Handle cross-platform compilation (Windows, macOS, Linux)
- Manage ABI compatibility between Electron and native modules
- Configure prebuild/prebuild-install for binary distribution
- Set up N-API modules for version-independent builds
- Handle architecture-specific builds (x64, arm64, ia32)
- Integrate with electron-builder for packaging
## Input Schema
```json
{
"type": "object",
"properties": {
"projectPath": {
"type": "string",
"description": "Path to the Electron project root"
},
"nativeModules": {
"type": "array",
"description": "List of native modules to handle",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"version": { "type": "string" },
"source": { "enum": ["npm", "local", "github"] }
}
}
},
"electronVersion": {
"type": "string",
"description": "Target Electron version"
},
"targetPlatforms": {
"type": "array",
"items": { "enum": ["win32", "darwin", "linux"] }
},
"targetArchitectures": {
"type": "array",
"items": { "enum": ["x64", "arm64", "ia32"] }
},
"useNAPI": {
"type": "boolean",
"description": "Use N-API for version-independent builds",
"default": true
},
"prebuildConfig": {
"type": "boolean",
"description": "Generate prebuild configuration",
"default": false
}
},
"required": ["projectPath"]
}
```
## Output Schema
```json
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"configuration": {
"type": "object",
"properties": {
"electronRebuild": { "type": "object" },
"nodeGyp": { "type": "object" },
"packageJson": { "type": "object" }
}
},
"scripts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"command": { "type": "string" }
}
}
},
"warnings": { "type": "array", "items": { "type": "string" } }
},
"required": ["success"]
}
```
## Configuration Methods
### electron-rebuild (Recommended)
```json
// package.json
{
"scripts": {
"postinstall": "electron-rebuild",
"rebuild": "electron-rebuild -f -w native-module-name"
},
"devDependencies": {
"@electron/rebuild": "^3.6.0"
}
}
```
### node-gyp with Electron Headers
```bash
# Set Electron headers for node-gyp
export npm_config_target=28.0.0
export npm_config_arch=x64
export npm_config_target_arch=x64
export npm_config_disturl=https://electronjs.org/headers
export npm_config_runtime=electron
export npm_config_build_from_source=true
npm install native-module
```
### electron-builder Integration
```yaml
# electron-builder.yml
npmRebuild: true
buildDependenciesFromSource: true
nodeGypRebuild: false
asarUnpack:
- "**/*.node"
- "**/node_modules/native-module/**"
```
## N-API Configuration
N-API provides ABI stability across Node.js versions:
```javascript
// binding.gyp for N-API module
{
"targets": [
{
"target_name": "native_module",
"sources": ["src/native_module.cc"],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")"
],
"dependencies": [
"<!(node -p \"require('node-addon-api').gyp\")"
],
"defines": ["NAPI_VERSION=8", "NAPI_DISABLE_CPP_EXCEPTIONS"]
}
]
}
```
## Prebuild Configuration
For distributing prebuilt binaries:
```json
// package.json
{
"scripts": {
"prebuild": "prebuild -t 28.0.0 -r electron -a x64 -a arm64",
"prebuild-upload": "prebuild --upload-all $GITHUB_TOKEN"
},
"devDependencies": {
"prebuild": "^12.1.0",
"prebuild-install": "^7.1.1"
}
}
```
## Cross-Compilation
### Windows from macOS/Linux
```bash
# Using electron-rebuild with wine
npx @electron/rebuild --platform=win32 --arch=x64
# Or with prebuild
prebuild -t 28.0.0 -r electron --platform=win32 --arch=x64
```
### macOS ARM64 from x64
```bash
# Requires Xcode and arm64 toolchain
npx @electron/rebuild --arch=arm64
```
### Linux from macOS/Windows
```bash
# Using Docker
docker run -v $(pwd):/project electron-builder-linux \
npx @electron/rebuild --platform=linux --arch=x64
```
## Common Native Modules
| Module | Use Case | N-API Support |
|--------|----------|---------------|
| better-sqlite3 | SQLite database | Yes |
| sharp | Image processing | Yes |
| node-pty | Terminal emulation | Yes |
| serialport | Serial communication | Yes |
| robotjs | Desktop automation | Limited |
| node-hid | USB HID devices | Yes |
## Troubleshooting
### ABI Mismatch Error
```
Error: The module was compiled against a different Node.js version
```
**Solution**: Rebuild with correct Electron version:
```bash
npx @electron/rebuild -v 28.0.0
```
### Missing Build Tools
**Windows**: Install Visual Studio Build Tools
```bash
npm install -g windows-build-tools
```
**macOS**: Install Xcode Command Line Tools
```bash
xcode-select --install
```
**Linux**: Install build-essential
```bash
sudo apt-get install build-essential
```
### Python Version Issues
```bash
# Specify Python version for node-gyp
npm config set python /usr/bin/python3
```
## Best Practices
1. **Use N-API when possible**: Provides version-independent binaries
2. **Prebuild binaries**: Avoid compilation on user machines
3. **Test all platforms**: Native modules behave differently per OS
4. **Pin Electron version**: Ensure ABI compatibility
5. **Exclude from ASAR**: Native modules must be unpacked
6. **Use electron-rebuild**: Handles headers automatically
## Related Skills
- `electron-builder-config` - Package native modules correctly
- `electron-main-preload-generator` - Secure native module usage
- `cross-platform-test-matrix` - Test native modules across platforms
## Related Agents
- `electron-architect` - Architecture for native modules
- `desktop-ci-architect` - CI/CD for native module builds
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.