I'm experimenting with Node-Webkit lately, if I call sth like that;
exports.name = function() {
console.log('My name is Uğur');
};
Node-WebKit renderer throws a error:
"Uncaught ReferenceError: exports is not defined"
I couldn't understand, Is it caused by node-webkit or node.js itself. Since; 'node test.js' works without problem.
You need to run this in the Node's context (not WebKit's context). To do that, specify the script in 'node-main' in the manifest.
Here is an example:
index.js:
exports.callback0 = function (win) {
}
index.html:
<body onload="process.mainModule.exports.callback0(window)">
package.json:
{
"name": "nw-demo",
"node-main": "index.js",
"main": "index.html"
}
HTH