Reputation: 2760
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.
Upvotes: 5
Views: 5128
Reputation: 2475
This may help some people if they want see a quick output without much effort.
Folder
index.html
package.json
nwjs (the extract executable file)
js
css
Then you just double click the nw.js, you could see the index running.
Work on macOS 10.12.2 with nwjs v0.19.4
Upvotes: 0
Reputation: 3976
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>
Upvotes: 1
Reputation: 34038
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!
Upvotes: 12