Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get my node-webkit app to open correctly?

I'm working on setting up my first node-webkit app and I'm running into issues launching it. I'm on a Mac and the app file structure looks the same as below.

Folder
 index.html
 package.json

Package.json

{
  "name": "Test App",
  "main": "index.html",
  "window": {
    "toolbar": true,
    "width": 800,
    "height": 600
  }
}

I then ran 'zip data *' in the terminal to zip the app and rename the zip file to 'app.nw'.

When I drag the nw file or the original folder onto node-webkit, it doesn't open my app correctly, instead it displays the default screen.

enter image description here

like image 235
mike Avatar asked Sep 22 '14 02:09

mike


2 Answers

For development purposes, which it sounds like is what you're doing, you don't need to zip up the application bundle each time. This would be time consuming and wasteful, and if we as developers had to do that every time we made a change, many more of us would be foaming at the mouth crazy, not getting anything done, and despising our roles as programmers. :)

Instead, you can run straight from the codebase by installing the nodewebkit module globally:

$ sudo npm install -g nodewebkit

Then assuming you are in the folder containing the package.json file, you can start the application via the following command:

$ nodewebkit .

But this is just skimming the surface of all of the cool things you can do to keep yourself from going insane and donning that straight-jacket! Several people in the node-webkit community have built some really awesome tools, in full Kathy Sierra style, that create passionate developers who are awesome at their jobs.

First and foremost is Gaze. This is a livereload module that will actually reload the node-webkit app after every change you make. That's a far cry from the zip, run, test, make changes, zip, run, test cycle that many of us have been prisoners to in the past.

With that said, it sounds like you're just starting out with this platform. My suggestion is, whenever you find something you need to do, just google "npm +whatever it is you're trying to do" and there may very well be a module or some open source code to quickly help get you from point A to point B. Hope this helps!

like image 132
jmort253 Avatar answered Oct 19 '22 14:10

jmort253


another way i did is create alias for node webkit binary on .bash_profile

to simplify you can copy the nwjs file (nwjs.app) from downloaded source to Applications directory, and then open the .bash_profile

sudo nano ~/.bash_profile

and add the following line

# alias to nw
alias nw="/Applications/nwjs.app/Contents/MacOS/nwjs"

dont forget to refresh the bash profile

source ~/.bash_profile

after that you can run your node webkit app by command

nw <path to your app>
like image 1
Lafif Astahdziq Avatar answered Oct 19 '22 16:10

Lafif Astahdziq