Robert Carter Mills
Robert Carter Mills

Reputation: 793

Node webkit package not opening properly from double click in OSX Finder

I've created a very simple app.nw package with the minimal 'hello world' setup, according to nw.js/README.md. It consists of only two files:

index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    We are using node.js <script>document.write(process.version)</script>.
  </body>
</html>

package.json

{
  "name": "nw-demo",
  "version": "0.0.1",
  "main": "index.html"
}

It works fine when run from the console like this:

/Applications/nwjs.app/Contents/MacOS/nwjs myapp.nw

However when I double click myapp.nw in the Finder it opens the default nwjs files, not my app.

I am developing an app for non-technical users who will not open the Terminal. We can have them download and install nwjs.app into their Applications folder, but then we need them to be able to just download and double click the app package.

I was able to get my app to execute from a double click in the Finder by copying myapp.nw package into the Resources directory of a copy of nwjs.app and renaming it to app.nw as per nwjs packaging documentation, however this integrates our custom code into the very large nwjs.app distributable (93.8MB). This is an unacceptable size to ask our users to download each time.

How can I enable my node webkit package (which contains only our specific application code and assets) to be opened directly from OSX Finder?

Upvotes: 0

Views: 385

Answers (1)

Kuf
Kuf

Reputation: 17846

You need to pack the file into an executable. For more information, check out this guide on the project git.

My recommendation is that you won't do it manually. Instead use grunt to pack your files. To get started, use yeoman and generator-node-webkit for a basic project layout and build script.

Then, making the executable is easy as:

grunt dist-mac

Upvotes: 0

Related Questions