{"id":13527387,"url":"https://github.com/prebuild/prebuild","last_synced_at":"2025-05-15T05:07:58.537Z","repository":{"id":35429544,"uuid":"39695266","full_name":"prebuild/prebuild","owner":"prebuild","description":"A command line tool for easily doing prebuilds for multiple version of node on a specific platform","archived":false,"fork":false,"pushed_at":"2024-06-09T19:24:02.000Z","size":400,"stargazers_count":437,"open_issues_count":24,"forks_count":77,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-22T12:57:21.159Z","etag":null,"topics":["electron","native-development","prebuild","prebuilt-binaries"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prebuild.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-07-25T17:13:57.000Z","updated_at":"2025-04-21T09:01:01.000Z","dependencies_parsed_at":"2024-01-13T21:40:55.019Z","dependency_job_id":"aa68defd-53f2-4730-811b-765c4922a2ec","html_url":"https://github.com/prebuild/prebuild","commit_stats":{"total_commits":417,"total_committers":33,"mean_commits":"12.636363636363637","dds":0.5827338129496402,"last_synced_commit":"e148f4554fa1fa435b79f5964c5fc06c9bda1331"},"previous_names":["mafintosh/prebuild"],"tags_count":116,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prebuild%2Fprebuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prebuild%2Fprebuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prebuild%2Fprebuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prebuild%2Fprebuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prebuild","download_url":"https://codeload.github.com/prebuild/prebuild/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","native-development","prebuild","prebuilt-binaries"],"created_at":"2024-08-01T06:01:46.913Z","updated_at":"2025-05-15T05:07:53.527Z","avatar_url":"https://github.com/prebuild.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# prebuild\n\n\u003e A command line tool for easily making prebuilt binaries for multiple versions of [Node.js](https://nodejs.org/en/), [Node-API](https://nodejs.org/api/n-api.html#n_api_node_api), [Electron](http://electron.atom.io/) and [NW.js](https://nwjs.io/) on a specific platform.\n\n```\n$ npm install -g prebuild\n```\n\n[![npm](https://img.shields.io/npm/v/prebuild.svg)](https://www.npmjs.com/package/prebuild)\n![Node version](https://img.shields.io/node/v/prebuild.svg)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\n## Features\n\n* Builds native modules for any version of Node.js, Node-API, Electron or NW.js, 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.\n* Upload (`--upload`) prebuilt binaries to GitHub.\n* Support for stripping (`--strip`) debug information. Strip command defaults to `strip` but can be overridden by the `STRIP` environment variable.\n* Install prebuilt modules via [`prebuild-install`](https://github.com/prebuild/prebuild-install).\n\n## Building\n\nBuilding is only required for targets with different [ABI](https://en.wikipedia.org/wiki/Application_binary_interface) versions. To build for all *supported* ABI versions ([example from leveldown](https://github.com/Level/leveldown/blob/ea5999dbd5fddf8f811b6c14162a3282b24ef7a9/package.json#L55)):\n\n```\nprebuild --all\n```\n\n*Supported* ABI versions may change over time without a new prebuild release.\n\nAlternatively, to build for some specific versions you can do:\n\n```\nprebuild -t 0.10.42 -t 0.12.10 -t 4.3.0\n```\n\nTo build for Node-API, do:\n\n```\nprebuild -t 3 -r napi\n```\n\nTo build against Electron headers, do:\n\n```\nprebuild -t 1.4.10 -r electron\n```\n\nTo build against NW.js headers, do:\n\n```\nprebuild -t 0.26.6 -r node-webkit\n```\n\nSee [`allTargets`](https://github.com/lgeiger/node-abi#usage) for all available versions.\n\nFor more options run `prebuild --help`. The prebuilds created are compatible with [node-pre-gyp](https://github.com/mapbox/node-pre-gyp)\n\nIf you'd like to include other files with your prebuilds like additional\n`.node` files or other native libraries, you can pass a file-matching regular\nexpression to `--include-regex`:\n\n```\nprebuild -t 8.0.0 --include-regex \"\\.(node|a)$\"\n```\n\nNote that if you include multiple `.node` files, you will need to use the\nprebuild-install's `--binary-name` parameter to indicate which file should be\nloaded:\n\n```\nprebuild-install --binary-name main-binary.node\n```\n\nThe build file format is selected automatically by `node-gyp`, however it is possible to specify needed format explicitly with `--format` parameter.\nThis is particularly useful if unusual flavor is required, which could be specified in 'format-flavor' form\n(there is no comprehensive list of formats/flavors available so one has to find possible combinations from `node-gyp` source code).\nFor example, in order to build using Makefiles but assume Android cross-compilation:\n\n```\nprebuild --format make-android\n```\n\nWhen using the [cmake-js](https://www.npmjs.com/package/cmake-js) backend additional parameters can be passed through.\n\n```\nprebuild --backend cmake-js -- --prefer-clang --CDUV_INCLUDE_DIR=...\n```\n\n## Scripts\n\nA prepack script can be specified that is executed once the `.node` module has been created but before it is compressed and moved. This can be used to perform code signing.\n\n```\nprebuild --prepack 'codesign -v -s MyCompany'\n```\n\nThe `--preinstall` or `--prepack` parameters can take either a shell command or JS file to be executed.\n\n## Uploading\n\n`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 \u003cgithub-token\u003e` option:\n\n```\n$ prebuild --all -u \u003cgithub-token\u003e\n```\n\nIf you don't want to use the token on cli you can put it in `~/.prebuildrc`:\n\n```\nupload=\u003cgithub-token\u003e\n```\n\nNote that `--upload` will only upload the targets that was built and stored in `./prebuilds`, so `prebuild -u \u003cgithub-token\u003e -t 4.3.0` will only upload the binary for the `4.3.0` target.\n\nYou can use `prebuild --upload-all` to upload all files from the `./prebuilds` folder.\n\nYou can use `prebuild --upload --tag-prefix \u003cprefix\u003e` for specific tag prefixes for the release. The default prefix is `v` and will result in a tag with an appended version number, for example `v1.0.0`. For [lerna](https://github.com/lerna/lerna) you can use the package name e.g. `prebuild --tag-prefix some-package@` and the binaries will be released on the appropriate package's tags, for example `some-package@1.0.0`.\n\nYou can use `prebuild --upload --prerelease` to create a prerelease, which will not be shown as the latest release.\n\n## Create GitHub Token\n\nA GitHub token is needed for two reasons:\n\n* Create a GitHub release ([leveldown example](https://github.com/Level/leveldown/releases/tag/v1.4.4))\n* Upload the prebuilt binaries to that release\n\nTo create a token:\n\n* Go to [this page](https://github.com/settings/tokens)\n* Click the `Generate new token` button\n* Give the token a name and click the `Generate token` button, see below\n\n![prebuild-token](https://cloud.githubusercontent.com/assets/13285808/20844584/d0b85268-b8c0-11e6-8b08-2b19522165a9.png)\n\nThe default scopes should be fine.\n\n## Node-API Considerations\n\n### Declaring Supported Node-API Versions\n\nNative modules that are designed to work with [Node-API](https://nodejs.org/api/n-api.html#n_api_node_api), which was previously known as N-API, must explicitly declare the Node-API version(s) against which they can build. This is accomplished by including a `binary` property on the module's `package.json` file. For example:\n\n```json\n\"binary\": {\n  \"napi_versions\": [2,3]\n}\n```\n\nIn the absence of a need to compile against a specific Node-API version, the value `3` is a good choice as this is the Node-API version that was supported when Node-API left experimental status.\n\nModules that are built against a specific Node-API version will continue to operate indefinitely, even as later versions of Node-API are introduced.\n\n### Defining the `NAPI_VERSION` Value\n\nThe Node-API header files supplied with Node use the `NAPI_VERSION` preprocessor value supplied by the user to configure each build to the specific Node-API version for which the native addon is being built. In addition, the module's C/C++ code can use this value to conditionally compile code based on the Node-API version it is being compiled against.\n\n`prebuild` supports two build backends: [`node-gyp`](https://github.com/nodejs/node-gyp) and [`cmake-js`](https://github.com/cmake-js/cmake-js). The `NAPI_VERSION` value is configured differently for each backend.\n\n#### node-gyp\n\nThe following code must be included in the `binding.gyp` file of modules targeting Node-API:\n\n```json\n\"defines\": [\n  \"NAPI_VERSION=\u003c(napi_build_version)\",\n]\n```\n\n#### cmake-js\n\nThe following line must be included in the `CMakeLists.txt` file of modules targeting Node-API:\n\n```cmake\nadd_compile_definitions(NAPI_VERSION=${napi_build_version})\n```\n\n### `prebuild` arguments\n\nThe `--runtime` argument must be `napi` to request Node-API builds. When requesting Node-API builds, the module's `package.json` file _must_ include a `binary` property as described above. And the `binding.gyp` file _must_ include a define for `NAPI_VERSION` as described above.\n\nOne or more `--target` arguments may be specified to request builds for specific Node-API versions. Node-API versions are positive integer values. Alternatively, `--all` may be used to request builds for all Node-API versions supported by the module.\n\nIn the absence of both `--target` and `--all` arguments, `prebuild` will build the most current version of the module supported by the Node instance performing the build.\n\n## Help\n\n```\n$ prebuild -h\nprebuild [options]\n\n  --target      -t  version     (version to build or install for)\n  --runtime     -r  runtime     (Node runtime [node, napi, electron or node-webkit] to build or install for, default is node)\n  --arch        -a  arch        (architecture to build or install for [default: process.arch])\n  --all                         (prebuild for all known abi versions)\n  --upload      -u  [gh-token]  (upload prebuilds to github)\n  --upload-all  -u  [gh-token]  (upload all files from ./prebuilds folder to github)\n  --tag-prefix \u003cprefix\u003e         (github tag prefix, default is \"v\")\n  --preinstall  -i  script      (run this script before prebuilding)\n  --prepack     -c  script      (run this script before packing, can be used to codesign)\n  --path        -p  path        (make a prebuild here)\n  --include-regex               (regex to match files that will be distributed [default: '\\.node$'])\n  --libc                        (use provided libc rather than system default)\n  --backend                     (specify build backend, default is 'node-gyp')\n  --format                      (specify additional parameters for `node-gyp` backend)\n  --strip                       (strip debug information)\n  --debug                       (set Debug or Release configuration)\n  --verbose                     (log verbosely)\n  --version                     (print prebuild version and exit)\n```\n\n## JavaScript API\n\n```js\nvar prebuild = require('prebuild')\n```\n\n### .build(opts, version, cb)\n\nOptions:\n\n- `.log` (optional)\n- `.preinstall` (optional)\n- `.gyp` Provide a custom `node-gyp` instance (optional)\n- `.backend` Provide a custom `node-gyp` instance via string. Alternatives are `'node-gyp'`, `'node-ninja'`, `'nw-gyp'` and `'cmake-js'` (optional, defaults to `'node-gyp'`)\n- `.args` Additional command line arguments to `node-gyp` (optional)\n- `.debug` Pass in `--debug` on command line to gyp backend (optional)\n\nExample:\n\n```js\nprebuild.build({}, version, function (err) {\n  // ...\n})\n```\n### Global options:\n\n- `.debug` Download or build a debug build (default: `false`)\n- `.arch` Processor architecture (default: `process.arch`)\n\n## Develop `prebuild`\n\nIf you want to hack on `prebuild` you need an environment to play around with. We recommend a setup similar\nto the following:\n\n* A fork of `prebuild`\n* A GitHub token (see above)\n* A native node module\n\n```bash\n$ git clone git@github.com:\u003cyour-nick\u003e/prebuild\n$ cd prebuild \u0026\u0026 npm link \u0026\u0026 cd ..\n$ git clone git@github.com:\u003cyour-nick\u003e/some-native-module\n```\n\nSince you did `npm link` on `prebuild` it will be installed globally. Now you can go ahead and try things out.\n\n```bash\n$ cd some-native-module\n$ prebuild --all --strip -u \u003cgithub-token\u003e\n```\n\nThis command would:\n\n* Build `some-native-module` for all supported targets and store them in `./prebuilds/`\n* Strip binaries from debug information\n* Create a release on GitHub, if needed\n* Upload all binaries to that release, if not already uploaded\n\nBefore you commit your changes and send us a pull request, do run `npm test`.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprebuild%2Fprebuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprebuild%2Fprebuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprebuild%2Fprebuild/lists"}