package
Create binary artifacts hosted by github and install them without compiling.
npm install install-artifact-from-githubGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
61.5 kB
Includes dependencies.
This is a no-dependency micro helper for developers of binary addons for Node. It is literally three small one-file utilities integrated with GitHub releases:
In general, it can save your users from a long recompilation and, in some cases, even save them from installing build tools. By using GitHub facilities (Releases and Actions) the whole process of publishing and subsequent installations are secure, transparent, painless, inexpensive, or even free for public repositories.
Installation:
npm install --save install-artifact-from-githubIn your package.json (pseudo-code with comments):
{
// your custom package.json stuff
// ...
"scripts": {
// your scripts go here
// ...
// saves an artifact
"save-to-github": "save-to-github-cache --artifact build/Release/ABC.node",
// installs using pre-created artifacts
"install": "install-from-cache --artifact build/Release/ABC.node",
// used by "install" to test the artifact
"verify-build": "node scripts/verify-build.js",
// used by "install" to rebuild from sources
"rebuild": "node-gyp rebuild"
}
}Examples of GitHub actions can be found in the documentation.
install-from-cache can check that a downloaded binary is byte-for-byte the one you published — closing the gap where a network-downloaded artifact is trusted with no integrity check. It is opt-in and adds no dependency.
You pin a hash bag in your addon's package.json and let hash-github-cache maintain it, typically from a prepublishOnly hook:
{
"scripts": {
"prepublishOnly": "hash-github-cache --write"
}
}On npm publish, hash-github-cache hashes the release's assets and stamps an artifactHashes map ({"linux-x64-137": "sha256:...", ...}) into the packed package.json. Because that map ships in your immutable npm tarball, someone who swaps a GitHub release asset after publish cannot also rewrite the expected hash — so install-from-cache rejects the swapped binary and rebuilds from source instead. Verification runs only for downloads from your addon's own release location; a custom mirror (--host / DOWNLOAD_HOST) pointing elsewhere serves the deployer's own build and is intentionally not checked, while one pointing back at that location keeps its check.
To skip the prebuilt download entirely and always build from source (trusting only npm plus your own toolchain), set --force-build (or the DOWNLOAD_FORCE_BUILD environment variable).
See Verifying artifacts for the full picture.
Starting with npm 12 (July 2026), npm does not run dependency lifecycle scripts by default — and install-from-cache runs as your package's install script. Users of your addon have to approve it once (npm approve-scripts <your-package>), or neither the prebuilt download nor the node-gyp fallback will run. Document that step in your install instructions. See NPM 12 and install scripts for the full story.
The full documentation is in the wiki — browse the index, or search it by name.
install-from-cache under Corepack (thx, rainecheck); fixed redirect handling in all three bins; hash-github-cache --from-release now reaches GitHub Enterprise Cloud's API host and reads private releases.GITHUB_SERVER_URL is no longer consulted, and an addon's own repository.url now names its release host. Thx, Jack Myers.hash-github-cache bin records each published binary's SHA-256. Thx, ataberk-xyz.--napi / --napi-var / DOWNLOAD_NAPI swap the URL slot from ${abi} to napi-v${level}, collapsing the per-Node-major build matrix.--agent / --agent-var / ; converted to ESM; added an automated test suite; minimum Node bumped to 18.The full release history with dates is in the wiki: Release notes.
BSD-3-Clause — see LICENSE.
package.jsoninstall-from-cacheDOWNLOAD_AGENT