Function requireAddon

Source
Expand description

Runtime addon loader.

requireAddon<T = unknown>(options?: RequireAddonOptions): Promise<T>

Returns the native addon, running wget first when the binary is missing on disk.

With no arguments, the caller's source file is captured via util.getCallSites() and the enclosing package.json is discovered by walking up directories. Pass { from: import.meta.url } when the caller is not inside the consuming package.

T defaults to unknown; supply the addon's type at the call site to avoid narrowing each access.

throws

if provenance verification fails.

throws

if the download, decompression, or require fails.