npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tianyk/nw-builder

v3.7.4

Published

Build NW.js desktop applications for Mac, Windows and Linux.

Downloads

1

Readme

nw-builder

npm ci cd Join the chat at https://gitter.im/nwjs/nw-builder

Build NW.js applications for Mac, Windows and Linux.

Table of Contents

Installation

Tested and runs on Node 14, 16 and 18!

Using npm:

npm install nw-builder

Using yarn:

yarn add nw-builder

Using pnpm:

pnpm add nw-builder

Usage

CLI

Usage:
  nwbuild [options] [path] [-- <args>]

Options:
  -p, --platforms      Platforms to build, comma-sperated, can be:
                       win32, win64, osx32, osx64, linux32, linux64 or
                       win, osx, linux                                       [default: <Current OS>]
  -v, --version        The nw version, eg. 0.64.1                                 [default: "latest"]
  -r, --run            Runs NW.js for the current platform                          [default: false]
  -o, --buildDir       The build folder                                         [default: "./build"]
  -f, --forceDownload  Force download of NW.js                                      [default: false]
  --cacheDir           The cache folder
  --quiet              Disables logging                                             [default: false]
  -- <args>            Pass custom arguments to the NW.js instance
                       (-r, --run mode only)

To run NW.js in dev mode:

nwbuild -r path/to/app -- <args>

Module

var NwBuilder = require('nw-builder');
var nw = new NwBuilder({
    files: './path/to/nwfiles/**/**', // use the glob format
    platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
    version: 'latest',
    argv: ['<nwjs_arg>', ... ] // see nwjs docs for possible <nwjs_arg> values
});

// Log stuff you want
nw.on('log',  console.log);

nw.build().then(function () {
   console.log('all done!');
}).catch(function (error) {
    console.error(error);
});

To run NW.js in dev mode:

nw.run()
  .then(function () {
    console.log("all done!");
  })
  .catch(function (error) {
    console.error(error);
  });

API Reference

Stay up to date via the Changelog.

Options

options.files Required

Type: String Default value: null

The path to your node webkit app. It supports simple-glob so you can do stuff like ['foo/*.js', '!foo/bar.js', 'foo/bar.js'].

options.version

Type: String Default value: 'latest'

The version of NW.js you want to use. Per default it looks up the latest version. Here is a list of all available releases.

options.flavor

Type: String Default value: 'sdk'

The flavor of NW.js you want to use. Per default it will be sdk. Here is a list of all flavor available.

The value sdk is most used for development whereas normal for production.

options.platforms

Type (CLI): String (comma separated values) Type (API): Array of String Default value: [<current OS>]

The platforms you want to build. Can be ['win32', 'win64', 'osx32', 'osx64', 'linux32', 'linux64']

The values ['win', 'osx', 'linux'] can also be used and will build both the 32 and 64 bit versions of the specified platforms.

Be aware that the osx32 version can only be built with legacy version of nwjs. Since > 0.12.0, only 64 bits for osx works.

options.appName

Type: String Default value: false

The Name of your NW.js app. If this value is set to null, it will autodetect the name from your projects package.json. This will be used to generate a plist file for mac.

options.appVersion

Type: String Default value: false

The version of your NW.js app. If this value is set to null, it will autodetect the version form your projects package.json. This will be used to generate a plist file for mac.

options.buildDir

Type: String Default value: ./build

This is where the releases are saved.

options.cacheDir

Type: String Default value: ./cache

This is where the cached NW.js downloads are.

options.buildType

Type: String or function Default value: default

How you want to save your build.

  • default [appName]
  • versioned [appName] -v[appVersion]
  • timestamped [appName] - [timestamp];
  • A function with options as scope (e.g function () {return this.appVersion;} )

options.forceDownload

Type: Boolean Default value: false

This will delete everything in your build_dir directory, including the cached downloaded prebuilt binaries.

options.argv

Type (CLI): String (comma separated values) Type (API): Array of String Default Value: []

Pass Command Line Options when you run an NW.js instance. Ignored in case of build.

options.macCredits

Type: String Default value: false

MAC ONLY: The path to your credits.html file. If your don't provide your own it will use the one provided by NW.js

options.macIcns

Type: String Default value: false

MAC ONLY: The path to your ICNS icon file. If your don't provide your own it will use the one provided by NW.js

options.zip

Type: Boolean Default value: null

WINDOW ONLY: Instead of zipping the application and merging it into the executable the application content is placed next to the application (which speed up the startup time for large apps). The default behaviour is platform specific. For windows and linux, the application is zipped and merged into the executable. For mac, the application is not zipped.

options.zipOptions

Type: Object Default value: null

Allows to configure the underling zip library parameters, like store or compression ratio.

See archiver documentation for detailed description of properties.

options.macPlist

Type: String or Object Default value: false

MAC ONLY: Pass a string containing the path to your own plist file. If a string isn't passed, a plist file will be generated from your package.json. Pass an object to overwrite or add properties to the generated plist file.

options.winVersionString

Type: Object Default value: {}

WINDOWS ONLY: Some descriptors of the executable. If your don't provide your own FileDescription, it will default to options.appName. If you are building on MAC or LINUX you must have Wine installed to use this option.

See the MSDN docs for more options than the basic list below,

winVersionString: {
  'CompanyName': 'Some Company',
  'FileDescription': 'Process Name',
  'ProductName': 'Some Product',
  'LegalCopyright': 'Copyright 2017',
}

options.winIco

Type: String Default value: null

WINDOWS ONLY: The path to your ICO icon file. If your don't provide your own it will use the one provided by NW.js. If you are building on MAC or LINUX you must have Wine installed to use this option.

options.macZip (DEPRECATED)

Type: Boolean Default value: null

MAC ONLY: Use a app.nw folder instead of ZIP file, this significantly improves the startup speed of applications on mac, since no decompressing is needed. Builds on other platforms will still use ZIP files. The default behaviour of node-webkit-builder is to not use ZIP files on the mac platform. In case of the mac platform the option macZip can override the option zip.

options.mergeZip

Type: Boolean Default value: true

WINDOWS AND LINUX ONLY: Merge the source file package with the Node Webkit executable.

Manifest Options

platformOverrides

Allows you to specify platform-specific manifest values. Example manifest:

{
    "name": "nw-demo",
    "version": "0.1.0",
    "main": "index.html",
    "window": {
        "frame": false,
        "toolbar": false
    },
    "platformOverrides": {
        "win": {
            "window": {
                "toolbar": true
            }
        },
        "win32": {
            "window": {
                "frame": true,
                "toolbar": false
            }
        },
        "win64": {
            "window": {
                "frame": true
            }
        },
        "osx": {
            ...
        },
        "osx32": {
            ...
        },
        "osx64": {
            ...
        },
        "linux": {
            ...
        },
        "linux32": {
            ...
        },
        "linux64": {
            ...
        },
    }

The platform-specific options will override the others only when building that platform only and the platformOverrides property will be removed.

For example, when building for Windows, the manifest generated and put into the end app (from the manifest above) would be:

{
  "name": "nw-demo",
  "version": "0.1.0",
  "main": "index.html",
  "window": {
    "frame": true,
    "toolbar": false
  }
}

Additionally, when specifying multiple version of the same platform such as "win", "win32", and "win64", changes will be applied such that "win" applies to both "win32" and "win64", while "win32" and "win64" apply only to the specified version. Also note that "win32" and "win64" can further override changes made in "win".

See #85 and #94 for more information. If you need this during development too, see platform-overrides and gulp-platform-overrides. There is no Grunt plugin, yet.

## Troubleshooting

OSX ulimit

Darwin (OS X kernel) has a low limit for file descriptors (256 per process) by default, so you might get an EMFILE error or an error mentioning "too many open files" if youtry to open more file descriptors than this.

To get around it, run ulimit -n 1024 (or add it to your ~/.bash_profile). For more information, see henvic/osx-ulimit.

Team

This project was created by Steffen Müller and has been maintained by Gabe Paez, Andy Trevorah, Adam Lynch and Rémy Boulanouar in the past. This project is currently maintained by Ayushman Chhabra.

Contributing

Getting Started

  1. Pick and install a Node version manager
  2. Use your version manager to install Node 14.19, 16.9, 18.2 or above
  3. Run corepack enable
  4. corepack prepare [email protected] --activate
  5. pnpm install
  6. pnpm demo to test your changes at first glance
  7. pnpm test to run unit tests
  8. Don't forget to run pnpm format && pnpm lint before commiting your changes

General Guidelines

  • Whenever possible, open an issue before submitting a pull request.
  • PRs should have short descriptive titles. For example:
    • fix(docs): fix typo in options.platform description
    • feat(platform): add support for mac m1
  • Ideally, a PR should reference a related issue
  • Ensure there are tests that cover your changes

License

MIT