Elfy
Elfy

Reputation: 1863

Node-webkit run .js file only?

Is it possible for node-webkit to run a js file, and not a .html file?

I have a small app that is supposed to open a external url (and capture it to image), and I don't see the point of creating a html file with my script. I just want the script to run

Upvotes: 1

Views: 1006

Answers (2)

Jonathan Dodd
Jonathan Dodd

Reputation: 176

Starting with NW 12.0, a new manifest field, 'bg-script' allows for just this capability. The "main" field is NOT required (when "bg-script" is present) and no window will be opened, unless created in the js file. This provides an atom-shell-like "js rather than HTML" basic orientation to the app. Because this has just been added to NWJS, documentation and sample code have not caught up... so some experimentation will no doubt be required.

Upvotes: 3

Dhiraj
Dhiraj

Reputation: 33618

You can use "inject-js-end": "script.js". However, you should also have empty main like this "main": "".

If you choose this method, nw will still open a window and simply show the directory listing. In order to avoid that you can use the following to hide the window

"window": {
   "show": false
}

Upvotes: 1

Related Questions