1 | # nw
|
2 |
|
3 | An 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 |
|
9 | Please 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
|
14 | npm install -g nw
|
15 | ```
|
16 |
|
17 | You 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
|
22 | npm install --save-dev nw
|
23 | ```
|
24 |
|
25 | ### Specific version with changes to installer:
|
26 |
|
27 | ```shell
|
28 | npm 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
|
36 | npm 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 |
|
43 | Set `nwjs_platform` in `.npmrc` or `NWJS_PLATFORM` environment variable. Defaults to `process.platform`.
|
44 |
|
45 | ### Specify architecture:
|
46 |
|
47 | Set `nwjs_arch` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `process.arch`.
|
48 |
|
49 | ### Specify cache directory:
|
50 |
|
51 | Set `nwjs_cache_dir` in `.npmrc` or `NWJS_ARCH` environment variable. Defaults to `./node_modules/nw`.
|
52 |
|
53 | ### Specify cache flag:
|
54 |
|
55 | Set `nwjs_cache` in `.npmrc` or `NWJS_ARCH` environment variable to keep or delete cached binaries. Defaults to `true`.
|
56 |
|
57 | ### Specify ffmpeg flag:
|
58 |
|
59 | Set `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 |
|
63 | Set `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 |
|
67 | Set `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 |
|
71 | Add a script in your `package.json`:
|
72 |
|
73 | ```json
|
74 | {
|
75 | "scripts": {
|
76 | "start": "nw /path/to/app"
|
77 | }
|
78 | }
|
79 | ```
|
80 |
|
81 | Executing `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
|
88 | import { findpath } from 'nw';
|
89 | var path = findpath();
|
90 | ```
|
91 |
|
92 | ## Find the path to the chromedriver binary
|
93 |
|
94 | ``` js
|
95 | import { findpath } from 'nw';
|
96 | var path = findpath('chromedriver');
|
97 | ```
|
98 |
|
99 | ## Download specific versions independant of installer version
|
100 |
|
101 | ```js
|
102 | import { get } from 'nw';
|
103 |
|
104 | await get({
|
105 | // options
|
106 | });
|
107 | ```
|
108 |
|
109 | Options:
|
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.
|