Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# prebuild-install
> A command line tool to easily install prebuilt binaries for multiple version of node/iojs on a specific platform.
[](https://www.npmjs.com/package/prebuild-install)

[](https://travis-ci.org/prebuild/prebuild-install)
[](https://ci.appveyor.com/project/mathiask88/prebuild-install)
[](https://david-dm.org/prebuild/prebuild-install)
[](http://standardjs.com/)
`prebuild-install` supports installing prebuilt binaries from GitHub by default.
## Usage
Change your package.json install script to:
```json
{
"scripts": {
"install": "prebuild-install || node-gyp rebuild"
}
}
```
### Requirements
You need to provide prebuilds made by [`prebuild`](https://github.com/prebuild/prebuild).
### 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 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)
--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` and `--download`, may be passed through via
arguments given to the `npm` command.
### 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](https://developer.github.com/v3/rate_limit/)).
### Create GitHub Token
To create a token:
* Go to [this page](https://github.com/settings/tokens)
* Click the `Generate new token` button
* Give the token a name and click the `Generate token` button, see below

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
```
### 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`
## License
MIT