Package detail

nw

nwjs14.2kMIT0.101.0

An installer for NW.js

nw, nw.js, nwjs, chromium

readme

nw

An npm installer for NW.js.

npm

Install

Please go through the CHANGELOG carefully and choose the appropriate version. Bug fixes and feature updates are pushed to the repo periodically.

Latest version globally

npm install -g nw

You might run into issues installing globally. Learn how to fix this

Latest version of normal build flavor:

npm install --save-dev nw

Specific version with changes to installer:

npm install --save-dev nw@0.94.1-1

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:

{
  "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:

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

Find the path to the chromedriver binary

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

Download specific versions independant of installer version

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"` <defaults to host platform> Host platform npm install --save-dev --nwjs-platform nw nwjs_platform=linux NWJS_PLATFORM=linux get({ platform: "linux" })
arch `"ia32" \ "x64" \ "arm64"` <defaults to architecture platform> 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 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. 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's code and this installer use the MIT license.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

[0.94.1-1]

Added

  • Set allowExcessArguments to true in commander 6bcbfec

[0.91.0]

Changed

  • Move tests to seperate directory bd3fabb

Removed

  • Uninstall patch-package package 5b6cc97

[0.90.0-1]

Added

[0.88.0-5]

Changed

  • Coerce version prerelease type to string 992aa86

[0.88.0-4]

Changed

  • Detect build flavor during run mode. b4dbb64

[0.88.0-3]

Added

  • Get file path to NW.js directory. 5b37b6d

[0.88.0-2]

Changed

  • Spawned process inherits stdout and is not detached. df9fdc3

[0.88.0-1]

Changed

  • Correctly parse the prerelease object. 9802fb8

[0.88.0]

Changed

[0.87.0-4]

Added

[0.87.0-3]

Changed

  • Simplify prelease detection logic f35e2f5

[0.87.0-2]

Changed

  • Close zip file after reading all entries 5c481a7

[0.87.0-1]

Changed

  • Set default cache using __dirname 601911f

  • Pass CLI args to NW.js process. e5d6fb1

[0.87.0]

Changed

  • Allow passing unknown options to nw via commander acting as parser. 466494a

[0.86.0-3]

Changed

  • findpath looks for actual path and not symlink. On Windows, if user does not have Administrator privileges, symlink is not created, then findpath fails to find the file path. findpath is async with return type Promise<string> and has a secondary options argument. This is useful when you have multiple binaries. Here's an example of how to get the file path to ChromeDriver. 75a9fc0
const nwPath = await findpath('chromedriver', { flavor: 'sdk' });

[0.86.0-2]

Changed

  • Correct default path to NW.js binary

[0.86.0-1]

Changed

  • Fix module import.

[0.86.0]

Changed

  • Fix undefined version in parsing logic.

[0.85.0-4]

Added

  • Allow user to run specific binaries by specifing version, flavor, platform, arch and cacheDir options via CLI.

Changed

  • Fix run mode and remove workaround for disappearing Node manifest.

Removed

  • mac_plist and mac_icon CLI options.

[0.85.0-3]

Changed

  • Publish sdk version first.

[0.85.0-2]

Added

  • Re-add support for file:// which had been accidently removed in the previous release.
  • Expose get function as public API
import { get } from 'nw';

await get({
  // options
});

[0.85.0-1]

Added

  • Option to specify cache directory by setting nwjs_cache_dir in .npmrc or NWJS_CACHE_DIR as ENV variable. Defaults to ./node_modules/nw.

  • Option to customise caching behaviour by enabling/disabling nwjs_cache in .npmrc or NWJS_CACHE as ENV variable. Defaults to false.

  • Option to download community ffmpeg by enabling/disabling nwjs_ffmpeg in .npmrc or NWJS_FFMPEG as ENV variable. Defaults to false.

  • Option to download NW.js Node headers by enabling/disabling nwjs_native_addon in .npmrc or NWJS_NATIVE_ADDON as ENV variable. Defaults to false.

Changed

Switch from CJS to ESM.

ESM import:

import { findpath } from 'nw';

Previous CJS import:

    const { findpath } = require('nw');

Current CJS import:

    let nw;
    import('nw').then(object => {
        nw = object;
    });

Removed

  • CJS support.
  • compressing package.
  • cli-progress package.

[0.85.0]

Changed

  • Handle error when trying to create symlink on Windows as non-Administrator aca09ab
  • Symlink nwjs directory to nwjs-VERSION-PLATFORM-ARCH directory adc6d88

[0.81.0-3]

Changed

  • Append -sdk to version for SDK releases. 08785c3

[0.81.0-2]

Changed

  • Correctly decompress files post download. #122

[0.81.0-1]

Added

  • Detect ChromeDriver path #115

Changed

  • Refactor install script #115
  • Do not pin Node version in package.json. #106

0.79.0

Changed

  • Update merge dependency #95