Node -Webkit with an external module containing native code

I am using node -webkit with an external module called edge .

According to the document modules node -webkit, which contain their own code, must be recompiled with nw-gyp as opposed to node-gyp . I was able to recompile without errors and node -webkit seems to import the module in order.

Here is my code. The code I'm trying to use is:

 var edge = require('edge.node'); var hello = edge.func(function () {/* async (input) => { return ".NET welcomes " + input.ToString(); } */}); hello('Node.js', function (error, result) { if (error) throw error; console.log(result); }); 

Which causes the following error when starting in node -webkit.

 Uncaught TypeError: Object [object Object] has no method 'func' 

If I write the object to console.log , I see:

  Object {initializeClrFunc: function} initializeClrFunc: function () { [native code] } __proto__: Object 

So the module seems to have loaded. If I run the same code outside of node -webkit, everything works fine, and I can access the func function. It drives me crazy - and any help would really be appreciated.

+6
source share
1 answer

func method is provided by edge.js , a wrapper around its own edge.node module. Therefore, you should replace require('edge.node') with require('edge') .

0
source

Source: https://habr.com/ru/post/946514/


All Articles