prebuild-install
A command line tool for easily install prebuilds for multiple version of node/iojs on a specific platform
Last updated 9 years ago by ralphtheninja .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install prebuild-install 
SYNC missed versions from official npm registry.

prebuild-install

A command line tool to easily install prebuilt binaries for multiple versions of Node.js & Electron on a specific platform. By default it downloads prebuilt binaries from a GitHub release.

npm Node version Test Standard Common Changelog

Note

Instead of prebuild paired with prebuild-install, we recommend prebuildify paired with node-gyp-build.

With prebuildify, all prebuilt binaries are shipped inside the package that is published to npm, which means there's no need for a separate download step like you find in prebuild. The irony of this approach is that it is faster to download all prebuilt binaries for every platform when they are bundled than it is to download a single prebuilt binary as an install script.

Upsides:

  1. No extra download step, making it more reliable and faster to install.
  2. Supports changing runtime versions locally and using the same install between Node.js and Electron. Reinstalling or rebuilding is not necessary, as all prebuilt binaries are in the npm tarball and the correct one is simply picked on runtime.
  3. The node-gyp-build runtime dependency is dependency-free and will remain so out of principle, because introducing dependencies would negate the shorter install time.
  4. Prebuilt binaries work even if npm install scripts are disabled.
  5. The npm package checksum covers prebuilt binaries too.

Downsides:

  1. The installed npm package is larger on disk. Using Node-API alleviates this because Node-API binaries are runtime-agnostic and forward-compatible.
  2. Publishing is mildly more complicated, because npm publish must be done after compiling and fetching prebuilt binaries (typically in CI).

Usage

Use prebuild to create and upload prebuilt binaries. Then change your package.json install script to:

{
  "scripts": {
    "install": "prebuild-install || node-gyp rebuild"
  }
}

When a consumer then installs your package with npm thus triggering the above install script, prebuild-install will download a suitable prebuilt binary, or exit with a non-zero exit code if there is none, which triggers node-gyp rebuild in order to build from source.

Options (see below) can be passed to prebuild-install like so:

{
  "scripts": {
    "install": "prebuild-install -r napi || node-gyp rebuild"
  }
}

Help

prebuild-install [options]

  --download    -d  [url]       (download prebuilds, no url means github)
  --target      -t  version     (version to install for)
  --runtime     -r  runtime     (Node runtime [node, napi or electron] to build or install for, default is node)
  --path        -p  path        (make a prebuild-install here)
  --token       -T  gh-token    (github token for private repos)
  --arch            arch        (target CPU architecture, see Node OS module docs, default is current arch)
  --platform        platform    (target platform, see Node OS module docs, default is current platform)
  --tag-prefix <prefix>         (github tag prefix, default is "v")
  --build-from-source           (skip prebuild download)
  --verbose                     (log verbosely)
  --libc                        (use provided libc rather than system default)
  --debug                       (set Debug or Release configuration)
  --version                     (print prebuild-install version and exit)

When prebuild-install is run via an npm script, options --build-from-source, --debug, --download, --target, --runtime, --arch --platform and --libc may be passed through via arguments given to the npm command.

Alternatively you can set environment variables npm_config_build_from_source=true, npm_config_platform, npm_config_arch, npm_config_target npm_config_runtime and npm_config_libc.

Libc

On non-glibc Linux platforms, the Libc name is appended to platform name. For example, musl-based environments are called linuxmusl. If --libc=glibc is passed as option, glibc is discarded and platform is called as just linux. This can be used for example to build cross-platform packages on Alpine Linux.

Private Repositories

prebuild-install supports downloading prebuilds from private GitHub repositories using the -T <github-token>:

$ prebuild-install -T <github-token>

If you don't want to use the token on cli you can put it in ~/.prebuild-installrc:

token=<github-token>

Alternatively you can specify it in the prebuild-install_token environment variable.

Note that using a GitHub token uses the API to resolve the correct release meaning that you are subject to the (GitHub Rate Limit).

Create GitHub Token

To create a token:

  • Go to this page
  • Click the Generate new token button
  • Give the token a name and click the Generate token button, see below

prebuild-token

The default scopes should be fine.

Custom binaries

The end user can override binary download location through environment variables in their .npmrc file. The variable needs to meet the mask % your package name %_binary_host or % your package name %_binary_host_mirror. For example:

leveldown_binary_host=http://overriden-host.com/overriden-path

Note that the package version subpath and file name will still be appended. So if you are installing leveldown@1.2.3 the resulting url will be:

http://overriden-host.com/overriden-path/v1.2.3/leveldown-v1.2.3-node-v57-win32-x64.tar.gz

Local prebuilds

If you want to use prebuilds from your local filesystem, you can use the % your package name %_local_prebuilds .npmrc variable to set a path to the folder containing prebuilds. For example:

leveldown_local_prebuilds=/path/to/prebuilds

This option will look directly in that folder for bundles created with prebuild, for example:

/path/to/prebuilds/leveldown-v1.2.3-node-v57-win32-x64.tar.gz

Non-absolute paths resolve relative to the directory of the package invoking prebuild-install, e.g. for nested dependencies.

Cache

All prebuilt binaries are cached to minimize traffic. So first prebuild-install picks binaries from the cache and if no binary could be found, it will be downloaded. Depending on the environment, the cache folder is determined in the following order:

  • ${npm_config_cache}/_prebuilds
  • ${APP_DATA}/npm-cache/_prebuilds
  • ${HOME}/.npm/_prebuilds

Install

With npm do:

npm install prebuild-install

License

MIT

Current Tags

  • 7.1.2                                ...           latest (10 months ago)

47 Versions

  • 7.1.2                                ...           10 months ago
  • 7.1.1                                ...           3 years ago
  • 7.1.0                                ...           3 years ago
  • 7.0.1                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 6.1.4                                ...           3 years ago
  • 6.1.3                                ...           4 years ago
  • 6.1.2                                ...           4 years ago
  • 6.1.1                                ...           4 years ago
  • 6.1.0                                ...           4 years ago
  • 6.0.1                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 5.3.6                                ...           4 years ago
  • 5.3.5                                ...           4 years ago
  • 5.3.4                                ...           5 years ago
  • 5.3.3                                ...           5 years ago
  • 5.3.2                                ...           5 years ago
  • 5.3.1                                ...           5 years ago
  • 5.3.0                                ...           6 years ago
  • 5.2.5                                ...           6 years ago
  • 5.2.4                                ...           6 years ago
  • 5.2.3                                ...           6 years ago
  • 5.2.2                                ...           6 years ago
  • 5.2.1                                ...           6 years ago
  • 5.2.0                                ...           6 years ago
  • 5.1.0                                ...           6 years ago
  • 5.0.0                                ...           6 years ago
  • 4.0.0                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.5.3                                ...           7 years ago
  • 2.5.2                                ...           7 years ago
  • 2.5.1                                ...           7 years ago
  • 2.5.0                                ...           7 years ago
  • 2.4.1                                ...           7 years ago
  • 2.4.0                                ...           7 years ago
  • 2.3.0                                ...           7 years ago
  • 2.2.2                                ...           7 years ago
  • 2.2.1                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.2                                ...           8 years ago
  • 2.1.1                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (11)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE