UNPKG

3.9 kBMarkdownView Raw
1# nw
2
3An npm installer for [NW.js](https://nwjs.io).
4
5[![npm](https://img.shields.io/npm/v/nw)](https://www.npmjs.com/package/nw)
6
7## Install
8
9Please go through the [CHANGELOG](https://github.com/nwjs/npm-installer/blob/main/CHANGELOG.md) carefully and choose the appropriate version. Bug fixes and feature updates are pushed to the repo periodically.
10
11### Latest version globally
12
13```shell
14npm install -g nw
15```
16
17You might run into issues installing globally. [Learn how to fix this](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)
18
19### Latest version of normal build flavor:
20
21```shell
22npm install --save-dev nw
23```
24
25### Specific version with changes to installer:
26
27```shell
28npm install --save-dev nw@0.85.0-1
29```
30
31> You may use `npm view nw versions` to view the list of available versions.
32
33### Specify build flavor:
34
35```shell
36npm install --save-dev nw@sdk
37```
38
39> Optionally set `nwjs_build_type=sdk` in `.npmrc` or `NWJS_BUILD_TYPE=sdk` environment variable.
40
41### Specify platform:
42
43Set `nwjs_platform` in `.npmrc` or `NWJS_PLATFORM` environment variable. Defaults to `process.platform`.
44
45### Specify architecture:
46
47Set `nwjs_arch` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `process.arch`.
48
49### Specify cache directory:
50
51Set `nwjs_cache_dir` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `./node_modules/nw`.
52
53### Specify cache flag:
54
55Set `nwjs_cache` in `.npmrc` or `NWJS_ARCH` environment variable to keep or delete cached binaries. Defaults to `true`.
56
57### Specify ffmpeg flag:
58
59Set `nwjs_ffmpeg` in `.npmrc` or `NWJS_ARCH` environment variable to toggle downloading [community FFmpeg binaries](https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt). Defaults to `false`.
60
61### Specify Native Addon flag:
62
63Set `nwjs_native_addon` in `.npmrc` or `NWJS_NATIVE_ADDON` environment variable to toggle downloading NW.js Node headers. Defaults to `false`.
64
65### Specify download URL:
66
67Set `nwjs_urlbase` in `.npmrc`or `NWJS_URLBASE` environment variable. Defaults to `https://dl.nwjs.io`. The file system (`file://`) is also supported (for example, `file:///home/localghost/local_mirror`).
68
69## Usage
70
71Add a script in your `package.json`:
72
73```json
74{
75 "scripts": {
76 "start": "nw /path/to/app"
77 }
78}
79```
80
81Executing `npm start` runs the NW.js app. Omitting the file path makes NW.js check for valid project in current working directory. You can also call `nw` directly from `node_modules/.bin/nw`.
82
83## APIs
84
85### Find path to the NW.js binary:
86
87``` js
88import { findpath } from 'nw';
89var path = findpath();
90```
91
92## Find the path to the chromedriver binary
93
94``` js
95import { findpath } from 'nw';
96var path = findpath('chromedriver');
97```
98
99## Download specific versions independant of installer version
100
101```js
102import { get } from 'nw';
103
104await get({
105 // options
106});
107```
108
109Options:
110
111| Name | Type | Default | Description |
112| ---- | ------- | --------- | ----------- |
113| version | `string \| "latest" \| "stable"` | `"latest"` | Runtime version |
114| flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor |
115| platform | `"linux" \| "osx" \| "win"` | | Host platform |
116| arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
117| downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server |
118| cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
119| cache | `boolean` | `true`| If true the existing cache is used. Otherwise it removes and redownloads it. |
120| ffmpeg | `boolean` | `false`| If true the chromium ffmpeg is replaced by community version with proprietary codecs. |
121| nodeAddon | `false \| "gyp"` | `false` | Download Node headers |
122
123## License
124
125[NW.js](https://github.com/nwjs/nw.js)'s code and this installer use the MIT license.