Getting Started

erezcohen edited this page Apr 30, 2015 · 13 revisions

Setup

Create a folder for your application e.g.

$ mkdir myFirstNWApp

Then change into the newly created folder.

$ cd myFirstNWApp

Download the package necessary for initializing your app.

$ npm install generator-node-webkit

Initialize your app with the following command. For this you have to answer some questions about your app and select what platforms your app should be targeted on.

$ yo node-webkit

Now you are ready to start developing your application.

Structure

The node-webkit-generator creates the following folders.

Folder What is it for?

app

This is the folder where your node-webkit application will be go in. After first initialization there will be an hello world application inside. You can structure it how you want. The requirement is that the package.json file is directly in the app folder.

resources

This folder stores files necessary to build different distributions from your application e.g. the node-webkit binaries.

Building the application

To test your app you have to build a distribution from it. Depending on your development system you have to use one of the following grunt tasks.

On a linux call

$ grunt dist-linux # for 64bit
$ grunt dist-linux32 # for 32bit

On a pc call

$ grunt dist-win

On a mac call

$ grunt dist-mac # for 64bit
$ grunt dist-mac32 # for 32bit

The resulting application can then be found in the folder dist.

Running the application

You can run it now with the following commands depending again on your dev platform.

On a linux call

$ cd dist
$ ./node-webkit myfirstnwapp.app

On a mac call

$ dist/MacOS64/myfirstnwapp.app/Contents/MacOS/node-webkit

Combine creation and starting the app in one line with grunt

On a linux call

$ grunt dist-linux && cd dist && ./linux64/node-webkit myfirstnwapp.app

On a mac call

$ grunt dist-mac && dist/MacOS64/myfirstnwapp.app/Contents/MacOS/node-webkit
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.