For this purpose, we will use https://github.com/nwjs/nw-builder

Lets you build your NW.js apps for mac, win and linux via cli. It will download the prebuilt binaries for a newest version, unpacks it, creates a release folder, create the app.nw file for a specified directory and copies the app.nw file where it belongs.

First of all, install the node-webkit-builder module globally using:

$ npm install node-webkit-builder -g

Once the module has been installed, you can run the nwbuild command as follows:

$ nwbuild [options] [path]

Whereas path is the path to your project folder, options are the ones described in the following code:

-p Operating System to build ['osx32', 'osx64', 'win32', 'win64']
-v NW.js version [default: "latest"]
-r Runs NW.js project [default: false]
-o The path of the output folder [default: "./build"]
-f Force download of node-webkit [default: false]
--quiet Disables logging

Some examples:

  • Run a project (on the current platform):
$ nwbuild -v [version of your nw.js] -r /path/to/the/project
  • Build a project (executable file ( .exe )) for Win32 or/and Win64 platforms:
$ nwbuild -v [version of your nw.js] -p win32,win64 /path/to/the/project

If your cmd currently open in the project folder, instread write full path to your project you can just use dot symbol

$ nwbuild -v [version of your nw.js] -p win32,win64 .

I use NW.js 0.12.3

/application>nwbuild -v 0.12.3 -p win32,win64 .
Using v0.12.3
Create cache folder in C:/Users/User/AppData/Roaming/npm/node_modules/node-webkit-builder/
cache/0.12.3
Downloading: http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-ia32.zip
Create cache folder in C:/Users/User/AppData/Roaming/npm/node_modules/node-webkit-builder/
cache/0.12.3
Downloading: http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-x64.zip
  downloading [====================] 100% 0.0s

Create release folder in .../application/build/answer/win32
Create release folder in .../application/build/answer/win64
Zipping Thumbs.db
Zipping index.html
Zipping style.css
Zipping package.json

Files of project for test nw-builder:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>Hello World!</h1>
</body>
</html>

style.css

h1 {
    font-size: 100px;
    text-align: center;
}

package.json

{
    "name": "Test NW.js App",
    "main": "index.html",
    "version": "1.0.0",
    "dependencies": {
    },
    "window": {
        "title": "Test NW.js App",
        "width": 800,
        "height": 600,
        "icon": "icon.png",
        "toolbar": false
    }
}

Mikhail

I am Mikhail Evdokimov, a Hobbyist Self Taught Programmer