The Task

You have a node-webkit application and want to:

  • Distribute a single executable file instead of a bunch of files.
  • Protect the application's resources.
  • Change the exe's icon.
  • 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 in the packed exe. You can get the sample on GitHub.

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

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

Look at a typical set of files; there are nw.js runtime files and application files:

(This directory should be copied to the 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.
  • The application's files are available for anyone for extraction and modifications.
  • It's impossible to change the exe's icon and add a splashscreen.
  • There's 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 to the disk. They are totally in the memory.

Prepare the 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 the 32-bit version of nw.js runtime to ensure the packed exe will run on both 32-bit and 64-bit Windows.

Using the 64-bit nw.js runtime files, BoxedApp Packer will produce a 64-bit executable that won't run on 32-bit Windows.

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

Download BoxedApp Packer, launch it. Select nw.exe as the input exe, specify the 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 in the packed exe! Click "Override command line" and then type:
<BoxedAppVar:OldCmdLine> show-image-app
The packed exe will run as if show-image-app was passed.

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

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

Now it's time to import the application files. Again, click Import Directory and then 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.