CRQ CRQ - 3 months ago 29
Javascript Question

Node-Webkit's (nwjs) node-remote Usage

I wonder if someone can give me an example about how "node-remote" works if I want to run some of the logic/functions of my application from the server.

Like, I don't know what to do after adding "node-remote" : "hostip" into package.json, what should my server provide? .js file that has the functions I want to run? So is it like: "node-remote" : "" ? I am so confused about this...

I can't find enough information on web about this, so some help or at least a better explanation of "baconface"'s reply from this link would be so helpful:


node-remote is used for to expose node.js + nw.gui APIs for html script tags and javascript files coming from your website. That's it! You can use require, objects like global, process in these files.

node-remote parameter itself expects a domain name or ip address of hosts you want nw.js to allow to use node.js APIs for these hosts while other hosts can't access them.

Little example:

  1. configure simple package.json and set node-remote parameter to on it.
  2. save package.json.
  3. open nw application.
  4. open page on it.
  5. open Developer Tools.
  6. in console type require('fs').writeFileSync('test.txt', 'Hello, World!'); and hit enter.

Now you should see test.txt file in nw's root directory.

  1. delete test.txt.
  2. edit your package.json and remove node-remote field.
  3. repeat [2..6] actions.

Now you should see error like "require" is undefined in DevTools console

Hope this helps.