The Task

You have a node-webkit application and want:

  • to distribute a single executable file instead of a bunch of files.
  • to protect application's resources.
  • to change exe's icon.
  • to add a splashscreen.

For this tutorial let's use a simple application: it consists of an HTML file that shows an image. Both files will be included into the packed exe. You can get the sample on GitHub.

How do you distribute Node-WebKit application now? The Problems.

To distribute a node-webkit application you have to copy a lot of files: application's sources (*.html, *js, images and other resources), and node-webkit binaries.

Look at the typical set of files, there are nw.js runtime files and application files:

(This directory should be copied to client computer)
├───nwjs-v0.19.4-win-ia32
│   │   credits.html
│   │   d3dcompiler_47.dll
│   │   ffmpeg.dll
│   │   icudtl.dat
│   │   libEGL.dll
│   │   libGLESv2.dll
│   │   natives_blob.bin
│   │   node.dll
│   │   nw.dll
│   │   nw.exe
│   │   nw_100_percent.pak
│   │   nw_200_percent.pak
│   │   nw_elf.dll
│   │   resources.pak
│   │   snapshot_blob.bin
│   │   
│   └───locales
│           am.pak
│           ar.pak
│           ...
│           
└───show-image-app
        image.png
        index.html
        package.json
								

The standard approach has several serious problems:

  • No ways to prepare a single executable file of a node.js based application.
  • Application files are available for anyone for extraction and modifications.
  • It's impossible to change the exe's icon and add a splashscreen.
  • No ways to add a splashscreen.

BoxedApp Packer packs all the files together into a single exe file ("packed exe"). The packed exe doesn't unpack embedded files on the disk. They are totally in memory.

Prepare a package

First of all you need nw.js runtime, you can download it from the official nw.js website.

Important: runtime files bitness: 32-bit vs 64-bit.

Download 32-bit version of nw.js runtime to be sure the packed exe will run on both 32-bit and 64-bit Windows.

Using 64-bit nw.js runtime files, BoxedApp Packer prepares a 64-bit executable that doesn't run on 32-bit Windows.

At the same time if you use 32-bit nw.js runtime files, a 32-bit executable will be prepared that can run on both 32-bit and 64-bit Windows.

Download BoxedApp Packer, launch it. Select nw.exe as input exe, set output exe path (you can select any name).

To run node-webkit based application the folder name is passed to nw.exe, so the command line looks like:

> nw.exe show-image-app
Let's embed this command line into packed exe! Click to "Override command line" and type:
<BoxedAppVar:OldCmdLine> show-image-app
The packed exe will run as if show-image-app passed.

Then add nw.js runtime files: select Application Directory in the file tree, click to Add Files..., select runtime files (except nw.exe) and add the files.

Then click to Import Directory... and select "locales" (this folder is a part of the runtime).

Now it's time to import application files. Again click to Import Directory and select "show-image-app".

Build it and run. It works!

Screenshots

1. Select nw.exe
Select nw.exe
2. Set output name
Set output name
3. Override command line
Override command line
4. Add files
Add files
5. Import directories
Import directories
6. Build and run. It works!
Packed electron exe

Download

Both sources and BoxedApp Packer project are available on GitHub.