npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@oleavr/prebuild

v6.2.0

Published

A command line tool for easily doing prebuilds for multiple versions of node/iojs or electron on a specific platform

Downloads

2

Readme

prebuild

A command line tool for easily doing prebuilds for multiple versions of Node.js, io.js and Electron on a specific platform.

$ npm install -g prebuild

build status js-standard-style

Features

  • Builds native modules for any version of Node.js, io.js or Electron, without having to switch between different versions to do so. This works by only downloading the correct headers and telling node-gyp to use those instead of the ones installed on your system.
  • Upload (--upload) prebuilt binaries to GitHub.
  • Support for stripping (--strip) debug information.
  • Install prebuilt modules via prebuild-install.

Building

Building is only required for targets with different ABI versions. To build for all supported ABI versions greater than 0.8 (example from leveldown):

prebuild --all

Alternatively, to build for some specific versions you can do:

prebuild -t 0.10.42 -t 0.12.10 -t 4.3.0

To build against Electron headers, do:

prebuild -t 1.4.10 -r electron

See allTargets for all available versions.

For more options run prebuild --help. The prebuilds created are compatible with node-pre-gyp

Uploading

prebuild supports uploading prebuilds to GitHub releases. If the release doesn't exist, it will be created for you. To upload prebuilds simply add the -u <github-token> option:

$ prebuild --all -u <github-token>

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

upload=<github-token>

Note that --upload will only upload the targets that was built and stored in ./prebuilds, so prebuild -u <github-token> -t 4.3.0 will only upload the binary for the 4.3.0 target.

You can use prebuild --upload-all to upload all files from the ./prebuilds folder.

Create GitHub Token

A GitHub token is needed for two reasons:

  • Create a GitHub release (leveldown example)
  • Upload the prebuilt binaries to that release

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.

Help

$ prebuild -h
prebuild [options]

  --target      -t  version     (version to build or install for)
  --runtime     -r  runtime     (Node runtime [node or electron] to build or install for, default is node)
  --all                         (prebuild for all known abi versions)
  --upload      -u  [gh-token]  (upload prebuilds to github)
  --upload-all  -u  [gh-token]  (upload all files from ./prebuilds folder to github)
  --preinstall  -i  script      (run this script before prebuilding)
  --path        -p  path        (make a prebuild here)
  --libc                        (use provided libc rather than system default)
  --backend                     (specify build backend, default is 'node-gyp')
  --strip                       (strip debug information)
  --debug                       (set Debug or Release configuration)
  --verbose                     (log verbosely)
  --version                     (print prebuild version and exit)

JavaScript API

var prebuild = require('prebuild')

.build(opts, version, cb)

Options:

  • .log (optional)
  • .preinstall (optional)
  • .gyp Provide a custom node-gyp instance (optional)
  • .backend Provide a custom node-gyp instance via string. Alternatives are 'node-gyp' and 'node-ninja' (optional, defaults to 'node-gyp')
  • .args Additional command line arguments to node-gyp (optional)
  • .debug Pass in --debug on command line to gyp backend (optional)

Example:

prebuild.build({}, version, function (err) {
  // ...
})

Global options:

  • .debug Download or build a debug build (default: false)
  • .arch Processor architecture (default: process.arch)

Develop prebuild

If you want to hack on prebuild you need an environment to play around with. We recommend a setup similar to the following:

  • A fork of prebuild
  • A GitHub token (see above)
  • A native node module
$ git clone [email protected]:<your-nick>/prebuild
$ cd prebuild && npm link && cd ..
$ git clone [email protected]:<your-nick>/some-native-module

Since you did npm link on prebuild it will be installed globally. Now you can go ahead and try things out.

$ cd some-native-module
$ prebuild --all --strip -u <github-token>

This command would:

  • Build some-native-module for all supported targets and store them in ./prebuilds/
  • Strip binaries from debug information
  • Create a release on GitHub, if needed
  • Upload all binaries to that release, if not already uploaded

Before you commit your changes and send us a pull request, do run npm test.

License

MIT