Universalize
Combine built binaries into one universal binary
When you need this
On macOS, napi universalize combines the separate x86_64 (Intel) and
aarch64 (Apple Silicon) .node binaries into a single universal binary with
lipo. You need it only when you ship a darwin-universal target: your
napi.targets config must contain a universal-arch target for the current
platform, and both per-arch binaries must already be built. It currently runs
on macOS only.
In the release pipeline this command sits between napi build (run once per
macOS architecture) and napi artifacts. See Release native
packages for the complete pipeline.
Usage
# CLI
napi universalize [--options]
// Programmatically
import { NapiCli } from '@napi-rs/cli'
new NapiCli().universalize({
// options
})
Examples
A typical macOS CI job: build both architectures, then combine them:
napi build --release --target x86_64-apple-darwin
napi build --release --target aarch64-apple-darwin
napi universalize
Combine binaries that were written to a custom output directory (must match
the --output-dir used by napi build):
napi universalize --output-dir ./binaries
Options
| Options | CLI Options | type | required | default | description |
|---|---|---|---|---|---|
| --help,-h | get help | ||||
| cwd | --cwd | string | false | process.cwd() | The working directory of where napi command will be executed in, all other paths options are relative to this path |
| configPath | --config-path,-c | string | false | Path to napi config json file | |
| packageJsonPath | --package-json-path | string | false | package.json | Path to package.json |
| outputDir | --output-dir,-o | string | false | ./ | Path to the folder where all built .node files put, same as --output-dir of build command |