An open API service indexing awesome lists of open source software.

https://github.com/nwjs/npm-installer

npm installer for NW.js
https://github.com/nwjs/npm-installer

Last synced: 3 months ago
JSON representation

npm installer for NW.js

Awesome Lists containing this project

README

        

# nw

An npm installer for [NW.js](https://nwjs.io).

[![npm](https://img.shields.io/npm/v/nw)](https://www.npmjs.com/package/nw)

## Install

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.

### Latest version globally

```shell
npm install -g nw
```

You might run into issues installing globally. [Learn how to fix this](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)

### Latest version of normal build flavor:

```shell
npm install --save-dev nw
```

### Specific version with changes to installer:

```shell
npm install --save-dev [email protected]
```

> You may use `npm view nw versions` to view the list of available versions.

For more options, see the Options table below.

## Usage

Add a script in your `package.json`:

```json
{
"scripts": {
"start": "nw /path/to/app"
}
}
```

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`.

## APIs

### Find path to the NW.js binary:

``` js
import { findpath } from 'nw';
let path = await findpath();
```

## Find the path to the chromedriver binary

``` js
import { findpath } from 'nw';
let path = await findpath('chromedriver', { flavor: 'sdk' });
```

## Download specific versions independant of installer version

```js
import { get } from 'nw';

await get({
version: '0.14.7'
// other options
});
```

## Options:

| Name | Type | Default | Description | CLI Usage | .npmrc Usage | .env Usage | Module Usage |
| ---- | ------- | --------- | ----------- | --------- | ------------ | ---------- | ------------ |
| version | `string \| "latest" \| "stable"` | `"latest"` | Runtime version | `npm install --save-dev nw` | `` | `` | `get({ version: "latest" })` |
| flavor | `"normal" \| "sdk"` | `"normal"` | Runtime flavor | `npm install --save-dev nw@sdk` | `nwjs_build_type=sdk` | `export NWJS_BUILD_TYPE=sdk` | `get({ flavor: "sdk" })` |
| platform | `"linux" \| "osx" \| "win"` | `` | Host platform | `npm install --save-dev --nwjs-platform nw` | `nwjs_platform=linux` | `NWJS_PLATFORM=linux` | `get({ platform: "linux" })` |
| arch | `"ia32" \| "x64" \| "arm64"` | `` | Host architecture | `npm install --save-dev --nwjs-arch nw` | `nwjs_arch=x64` | `NWJS_ARCH=x64` | `get({ arch: "x64"})` |
| 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/ nw"` | `"https://dl.nwjs.io"` | Download server (https and file system is supported, for eg `file:///home/user/nwjs_cache`) | `npm install --save-dev --nwjs-urlbase=https://dl.nwjs.io` | `nwjs_urlbase=https://dl.nwjs.io` | `NWJS_URLBASE=https://dl.nwjs.io` | `get({ downloadUrl: "https://dl.nwjs.io"})` |
| cacheDir | `string` | `./node_modules/nw` | Directory to cache NW binaries | `npm install --save-dev --nwjs-cache-dir ./cache nw` | `nwjs_cache_dir=./cache` | `NWJS_CACHE_DIR=./cache` | `get({ cacheDir: "./cache" })` |
| sirDir | `string` | `.` | File path to NW.js project | `nw .` | `` | `` | `get({ srcDir: "." })` |
| cache | `boolean` | `true`| If true the existing cache is used. Otherwise it removes and redownloads it. | `npm install --save-dev --nwjs-cache=true nw` | `nwjs_cache=true` | `NWJS_CACHE=true` | `get({ cache: true })` |
| ffmpeg | `boolean` | `false`| If true the chromium ffmpeg is replaced by [community version](https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt) with proprietary codecs. | `npm install --save-dev --nwjs-ffmpeg=true nw` | `nwjs_ffmpeg=true` | `NWJS_FFMPEG=true` | `get({ ffmpeg: true })` |
| nodeAddon | `false \| "gyp"` | `false` | Download Node headers | `npm install --save-dev --nwjs-native-addon=true nw` | `nwjs_native_addon=true` | `NWJS_NATIVE_ADDON=true` | `get({ nativeAddon: true })` |
| unref | `boolean` | `false` | [Prevent the parent process from waiting for a given subprocess](https://nodejs.org/api/child_process.html#subprocessunref). This is useful if you're using `nw` package to call the executable and want to prevent zombie processes eating up memory. | `npm install --save-dev --nwjs-unref=true nw` | `nwjs_unref=true` | `NWJS_UNREF=true` | `get({ unref: true })` |
shaSum | `boolean` | `true` | If true, then shasums are verified. Otherwise, it is ignored. | `npm install --save-dev --nwjs-shasum=true nw` | `nwjs_shasum=true` | `NWJS_SHASUM=true` | `get({ shaSum: true })` |

> Note: While using the CLI interface, /path/to/project refers to options.srcDir in the JavaScript API or JSON object.

## License

[NW.js](https://github.com/nwjs/nw.js)'s code and this installer use the MIT license.