Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using require() in a remotely-hosted node-webkit application

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?

like image 943
CoryG Avatar asked Mar 25 '13 03:03

CoryG


1 Answers

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.

like image 136
CoryG Avatar answered Sep 26 '22 15:09

CoryG