Package and Distribute
This document guides you how to package and distribute NW.js based app.
You can use
nw-builder to quickly generate a package for you.
- Prepare your app as below.
npm install -g nw-builder
- Package your app with
nwbuild -p linux64 /path/to/your/app
Your app can be found in
Prepare Your App
Before packaging, you should prepare all necessary files on hands. Check out following checklist to make sure you didn’t miss anything:
- Source code and resources
- Install NPM modules with
- Rebuild native Node modules
- Build NaCl binaries
- Compile source code and remove the original files
- Icon used in manifest file
Do not assume your
node_modules that target one platform work as is in all platforms. For instance
node-email-templates has specific Windows & Mac OS X
npm install commands. Besides, it requires python to install properly, which is not installed by default on Windows.
As a rule of thumb
npm install your
package.json on each platform you target to ensure everything works as expected.
Filename and Path
On most Linux and some Mac OS X, the file system is case sensitive. That means
Test.js are different files. Make sure the paths and filenames used in your app have the right case. Otherwise your app may look bad or crash on those file systems.
Long Path on Windows
The length of path used in your app may exceed the maximum length (260 characters) on Windows. That will cause various build failures. This usually happens during installing dependencies with
npm install using older version of NPM (<3.0). Please build your app in the root directory, like
C:\build\, to avoid this issue as much as possible.
You have to redistribute NW.js with your app to get your app running. NW.js provided multiple build flavors for different requirements and package size. Choose the proper build flavor for your product or build it from source code.
All files in the downloaded package should be redistributed with your product, except
nwjc.exe in SDK flavor.
Package Your App
There two options to pack your app: plain files or zip file.
Package Option 1. Plain Files (Recommended)
On Windows and Linux, you can put the files of your app in the same folder of NW.js binaries and then ship them to your users. Make sure
nw.exe) is in the same folder as
package.json. Or you can put the files of your app in a folder named
package.nw in the same folder as
On Mac, put the files of your app into a folder named
nwjs.app/Contents/Resources/ and done.
It’s the recommended way to pack your app.
Package Option 2. Zip File
You can package all the files into a zip file and rename it as
package.nw. And put it along with NW.js binaries for Windows and Linux. For Mac, put
Start Slow with Big Package or Too Many Files
At starting time, NW.js will unzip the package into temp folder and load it from there. So it will start slower if your package is big or contains too many files.
On Windows and Linux, you can even hide the zip file by appending the zip file to the end of
You can run following command on Windows to achieve this:
copy /b nw.exe+package.nw app.exe
or following command on Linux:
cat nw app.nw > app && chmod +x app
Platform Specific Steps
On Linux, you need to create proper
To distribute your app through the package management sysmtem, like
pacman etc, please follow their official documents to create the packages.
Mac OS X
On Mac OS X, you need to modify following files to have your own icon and boundle id:
Contents/Resources/nw.icns: icon of your app.
nw.icnsis in Apple Icon Image Format. You can convert your icon in PNG/JPEG format into ICNS by using tools like Image2Icon.
Contents/Info.plist: the apple package description file. You can view Implementing Cocoa’s Standard About Panel on how this file will influence your app and what fields you should modify.
And you should sign you Mac app. Or the user won’t launch the app if Gatekeeper is turned on. See Signed Apps or Installer Packages for details.
See wiki of NW.js for more tools of packaging your app.