source: node_modules/prebuild-install/README.md@ 62b2964

finki-main main
Last change on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 7.3 KB
Line 
1# prebuild-install
2
3> **A command line tool to easily install prebuilt binaries for multiple versions of Node.js & Electron on a specific platform.**
4> By default it downloads prebuilt binaries from a GitHub release.
5
6[![npm](https://img.shields.io/npm/v/prebuild-install.svg)](https://www.npmjs.com/package/prebuild-install)
7![Node version](https://img.shields.io/node/v/prebuild-install.svg)
8[![Test](https://img.shields.io/github/workflow/status/prebuild/prebuild-install/Test?label=test)](https://github.com/prebuild/prebuild-install/actions/workflows/test.yml)
9[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript\&logoColor=fff)](https://standardjs.com)
10[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)
11
12## Note
13
14**Instead of [`prebuild`](https://github.com/prebuild/prebuild) paired with [`prebuild-install`](https://github.com/prebuild/prebuild-install), we recommend [`prebuildify`](https://github.com/prebuild/prebuildify) paired with [`node-gyp-build`](https://github.com/prebuild/node-gyp-build).**
15
16With `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.
17
18Upsides:
19
201. No extra download step, making it more reliable and faster to install.
212. 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.
223. 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.
234. Prebuilt binaries work even if npm install scripts are disabled.
245. The npm package checksum covers prebuilt binaries too.
25
26Downsides:
27
281. The installed npm package is larger on disk. Using [Node-API](https://nodejs.org/api/n-api.html) alleviates this because Node-API binaries are runtime-agnostic and forward-compatible.
292. Publishing is mildly more complicated, because `npm publish` must be done after compiling and fetching prebuilt binaries (typically in CI).
30
31## Usage
32
33Use [`prebuild`](https://github.com/prebuild/prebuild) to create and upload prebuilt binaries. Then change your package.json install script to:
34
35```json
36{
37 "scripts": {
38 "install": "prebuild-install || node-gyp rebuild"
39 }
40}
41```
42
43When 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.
44
45Options (see below) can be passed to `prebuild-install` like so:
46
47```json
48{
49 "scripts": {
50 "install": "prebuild-install -r napi || node-gyp rebuild"
51 }
52}
53```
54
55### Help
56
57```
58prebuild-install [options]
59
60 --download -d [url] (download prebuilds, no url means github)
61 --target -t version (version to install for)
62 --runtime -r runtime (Node runtime [node, napi or electron] to build or install for, default is node)
63 --path -p path (make a prebuild-install here)
64 --token -T gh-token (github token for private repos)
65 --arch arch (target CPU architecture, see Node OS module docs, default is current arch)
66 --platform platform (target platform, see Node OS module docs, default is current platform)
67 --tag-prefix <prefix> (github tag prefix, default is "v")
68 --build-from-source (skip prebuild download)
69 --verbose (log verbosely)
70 --libc (use provided libc rather than system default)
71 --debug (set Debug or Release configuration)
72 --version (print prebuild-install version and exit)
73```
74
75When `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.
76
77Alternatively 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`.
78
79### Libc
80
81On 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.
82
83### Private Repositories
84
85`prebuild-install` supports downloading prebuilds from private GitHub repositories using the `-T <github-token>`:
86
87```
88$ prebuild-install -T <github-token>
89```
90
91If you don't want to use the token on cli you can put it in `~/.prebuild-installrc`:
92
93```
94token=<github-token>
95```
96
97Alternatively you can specify it in the `prebuild-install_token` environment variable.
98
99Note that using a GitHub token uses the API to resolve the correct release meaning that you are subject to the ([GitHub Rate Limit](https://developer.github.com/v3/rate_limit/)).
100
101### Create GitHub Token
102
103To create a token:
104
105- Go to [this page](https://github.com/settings/tokens)
106- Click the `Generate new token` button
107- Give the token a name and click the `Generate token` button, see below
108
109![prebuild-token](https://cloud.githubusercontent.com/assets/13285808/20844584/d0b85268-b8c0-11e6-8b08-2b19522165a9.png)
110
111The default scopes should be fine.
112
113### Custom binaries
114
115The end user can override binary download location through environment variables in their .npmrc file.
116The variable needs to meet the mask `% your package name %_binary_host` or `% your package name %_binary_host_mirror`. For example:
117
118```
119leveldown_binary_host=http://overriden-host.com/overriden-path
120```
121
122Note that the package version subpath and file name will still be appended.
123So if you are installing `leveldown@1.2.3` the resulting url will be:
124
125```
126http://overriden-host.com/overriden-path/v1.2.3/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
127```
128
129#### Local prebuilds
130
131If 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:
132
133```
134leveldown_local_prebuilds=/path/to/prebuilds
135```
136
137This option will look directly in that folder for bundles created with `prebuild`, for example:
138
139```
140/path/to/prebuilds/leveldown-v1.2.3-node-v57-win32-x64.tar.gz
141```
142
143Non-absolute paths resolve relative to the directory of the package invoking prebuild-install, e.g. for nested dependencies.
144
145### Cache
146
147All 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:
148
149- `${npm_config_cache}/_prebuilds`
150- `${APP_DATA}/npm-cache/_prebuilds`
151- `${HOME}/.npm/_prebuilds`
152
153## Install
154
155With [npm](https://npmjs.org) do:
156
157```
158npm install prebuild-install
159```
160
161## License
162
163[MIT](./LICENSE)
Note: See TracBrowser for help on using the repository browser.