binary-distributor is an npm package that simplifies the distribution of platform-specific binary applications via npm.
It allows you to include and install pre-built binaries based on the user's system and architecture along with your
JavaScript module.
Usage
Initialize minimal npm package:
npm init -y
Pay attentions fields name
and version
should be defined and same as in your binary package.
Install binary-distributor:
npm install binary-distributor --save-dev
Add postinstall
and preuninstall
scripts to your package.json
:
{
"scripts": {
"postinstall": "binary-distributor install",
"preuninstall": "binary-distributor uninstall"
}
}
Add binary-distributor
section to your package.json
:
{
"binary-distributor": {
"url-template": "url/to/your/binary.tar.gz"
}
}
Following variables are available to customize the URL template:
{name}
- Name of the package read from package.json file.{version}
- Version number read from package.json file.{platform}
- Name of the operating system (Read more).{arch}
- The operating system CPU architecture (Read more).
Create launch script launch.js
with following content:
#!/usr/bin/env node
require('binary-distributor')
.launch(__dirname);
Add bin
section to your package.json
:
{
"bin": "./launch.js"
}
Then you can publish your package to npm registry:
npm publish
Support project