Question

I have a package.json file that looks like:

{
    "name": "title",
    "description": "description",
    "version": "0.1",
    "main": "https://path-to-application/",
    "window": {
        "show": true,
        "toolbar": false,
        "frame": true,
        "position": "center",
        "width": 800,
        "height": 600,
        "min_width": 220,
        "min_height": 220
    }
}

But when I attempt to run the code:

var GUI = null;
var win = null;
try { GUI = require('nw.gui'); win = GUI.Window.get(); } catch (ex) { }
win.toggleFullscreen();

Nothing happens, adding alerts for GUI and win show they are both set to null. When I run the same code from an index.html file within the same .zip as package.json it works as expected. It appears to be failing with the initial call to require().

Is there some way to get this working in a remotely hosted application?

Was it helpful?

Solution

I was able to solve this following by adding the node-remote field to the package.json file if anyone else runs into this issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top