Hi I am learning addon implementation. I am getting the error below.
This error coming from js file:
vec1.add_number(20,function(err,res)) SyntaxError: Unexpected token )
index.js:
var m = require('./');
var vec1 = new m.Vector(20, 10, 0); // call to new
vec1.add_number(20,function(err,res)) // **here is the error pls help to fix**
{
if(err)
console.error(err);
else
console.log('Final Result=%d',res);
testworker.cc
#include<nan.h>
#include "testWorker.h"
#include<iostream>
void TestWorker::Execute()
{
std::cout<<"its Execition\n";
myNumber +=6;
}
void TestWorker::Handleokcallback()
{
std::cout<<"Enter to Handleokcallback\n";
Nan::HandleScope scope;
auto numberjs= Nan::New(myNumber);
v8::local<v8::Value> argv[] ={Nan::Undefined,numberjs};
myCallback->call(2,argv);
}
module.js:435 return process.dlopen(module, path._makeLong(filename)); ^
Error: /home/admin1/Desktop/node-addon-tutorial-master/VectorExample/build/Release/myModule.node: undefined symbol: _ZTV10TestWorker at Error (native) at Object.Module._extensions..node (module.js:435:18) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object. (/home/admin1/Desktop/node-addon-tutorial-master/VectorExample/bindings.js:6:13) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32)
You have one extra )
in function(err,res))
and you're missing })
at the end.
Here's your code without syntax errors.
var m = require('./');
var vec1 = new m.Vector(20, 10, 0); // call to new
vec1.add_number(20,function(err,res) { // changed ) with {
if(err)
console.error(err);
else
console.log('Final Result=%d',res);
}); // Added this