UNPKG

5.74 kBMarkdownView Raw
1# nw [![Build Status](http://img.shields.io/travis/nwjs/npm-installer.svg)](https://travis-ci.org/nwjs/npm-installer)
2
3An installer for [nw.js](https://github.com/nwjs/nw.js).
4
5> nw.js is an app runtime based on Chromium and io.js. For building desktop applications that will run on OSX, Windows and Linux.
6
7[![NPM](https://nodei.co/npm/nw.png?downloads=true)](https://nodei.co/npm/nw/)
8
9## usage
10Install locally to your project with: `npm install nw` and then in your `package.json` add a script:
11
12```json
13{
14 "scripts": {
15 "start": "nw"
16 }
17}
18```
19
20Now it will run your local project when you type `npm start`.
21
22If your project is in another folder, add the path to the project `"start": "nw path/to/app"`.
23
24You could also call `nw` directly from `node_modules/.bin/nw` instead of adding to your `package.json`.
25
26### global
27You can also install globally with `npm install nw -g` and then in any project type `nw` to run the project. Installing locally is recommended though as each project can have its own dependent version of nw.js.
28
29## example
30If you want a really quick example try this:
31
321. `git clone https://github.com/zcbenz/nw-sample-apps && cd nw-sample-apps`
332. `npm init`
343. `npm install nw`
354. `"node_modules/.bin/nw" file-explorer`
36
37and now you should see a file explorer demo app.
38
39## command line options
40There are a few (platform-specific) arguments you can pass to the `nw` executable to
41customize your nw.js application:
42
43* `--mac_plist <path-to-plist-file>`: (OS X only) Copies the given file to Info.plist in the app
44 bundle. This lets you do things like change your app's name and point to a different icon.
45
46* `--mac_icon <path-to-icns-file>`: (OS X only) Copies the given .icns file to the Resources/ dir
47 in the app bundle. You will need to point to the file with a custom plist file as well (see
48 `--mac_list`)
49
50**NOTE**: These options will keep the copied files in the app bundle for as long as the bundle is
51on the filesystem (they're not deleted between app invocations). As a result, they're not
52recommended if you installed nw globally using `-g`. Also note that
53[OS X caches these files](http://proteo.me.uk/2011/08/mac-application-bundle-caching/),
54so you may need to manually clear these cached files during development.
55
56## install a specific version of nw.js
57
58To install a specific version of nw.js use npm with the specific version: `npm install nw@0.12.0`
59
60> *Please note:* This npm package version tracks the version of nw.js that will be installed, with an additional build number that is used for revisions to the installer. As such `0.12.0-1` and `0.12.0-2` will both install `nw.js@0.12.0` but the latter has newer changes to the installer.
61
62You may use `npm view nw versions` to view the list of available versions.
63
64## install a specific build type of nw.js
65
66nw.js has three build types: `normal`, `sdk` and `nacl`. To install a specific build type you may set npm config property `nwjs_build_type`, environment variable `NWJS_BUILD_TYPE` or pass command line option `--nwjs_build_type`:
67
68``` shell
69npm install nw --nwjs_build_type=sdk
70```
71
72Setting option in `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html):
73
74```
75nwjs_build_type=sdk
76```
77
78Setting environment variable `NWJS_BUILD_TYPE`:
79
80``` shell
81export NWJS_BUILD_TYPE=sdk
82```
83
84You can alternatively install `sdk` build by specifying `-sdk` suffix in version:
85
86``` shell
87npm install nw@0.13.3-sdk
88```
89
90You can also run `npm install nw@sdk` to get the latest of published SDK versions. (Note: that may be a beta version.)
91
92## install a specific architecture
93
94You may use the environment variable `npm_config_nwjs_process_arch` to override the default architecture (`process.arch`) and to download NW.js built for some other architecture.
95
96## finding the path to the nw.js binary
97
98If you would like to programmatically retrieve the path to the nw.js binary use:
99
100``` js
101var findpath = require('nw').findpath;
102var nwpath = findpath();
103// nwpath will equal the path to the binary depending on your environment
104```
105
106Then you can use that path to run NW.js programmatically. For example, to run in the current script's directory:
107
108```js
109require('child_process').spawn(
110 require('nw').findpath(),
111 ['.'].concat( process.argv.slice(2) ),
112 {
113 cwd: __dirname,
114 detached: true,
115 stdio: 'ignore'
116 }
117).unref();
118```
119
120## retrieve binaries from custom download location or file path
121
122The installer attempts to download binaries from the default location of `https://dl.nwjs.io/v`. You can override this by setting the npm config property `nwjs_urlbase` on the command line by passing the `--nwjs_urlbase` option:
123
124``` shell
125npm install nw --nwjs_urlbase=http://my.own.location/somewhere
126```
127
128or adding it to your `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html):
129
130```
131nwjs_urlbase=http://my.own.location/somewhere
132```
133
134You can alternatively set an environment variable `NWJS_URLBASE`:
135
136``` shell
137export NWJS_URLBASE=http://my.own.location/somewhere
138```
139
140The installer supports `file://` URLs to retrieve files from the local filesystem:
141
142``` shell
143export NWJS_URLBASE=file:///home/bilbo/my/own/mirror
144```
145
146## using a proxy with or without authentication
147
148If you are behind a proxy server you have to set an environment variable `http_proxy` with proxy servers url:
149
150```
151export http_proxy="http://username:password@myproxy.com:8080"
152```
153
154or
155
156```
157export http_proxy="http://myproxy.com:8080"
158```
159
160(However, if the environment variable `https_proxy` is set, then it will be preferred, as [programmed](https://github.com/kevva/get-proxy/blob/master/index.js) in the `get-proxy` package.)
161
162## license
163[nw.js](https://github.com/nwjs/nw.js)'s code and this installer use the MIT license.