【问题标题】:Nan::AsyncQueue is failed at runtimeNan::AsyncQueue 在运行时失败
【发布时间】:2018-04-08 15:42:08
【问题描述】:

您好,我正在学习插件实现。我收到以下错误。

这个错误来自js文件:

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)); ^

错误:/home/admin1/Desktop/node-addon-tutorial-master/VectorExample/build/Release/myModule.node:未定义符号:_ZTV10TestWorker 在错误(本机) 在 Object.Module._extensions..node (module.js:435:18) 在 Module.load (module.js:344:32) 在 Function.Module._load (module.js:301:12) 在 Module.require (module.js:354:17) 在要求(内部/module.js:12:17) 在对象。 (/home/admin1/Desktop/node-addon-tutorial-master/VectorExample/bindings.js:6:13) 在 Module._compile (module.js:410:26) 在 Object.Module._extensions..js (module.js:417:10) 在 Module.load (module.js:344:32)

【问题讨论】:

标签: javascript c++ node.js-addon


【解决方案1】:

您在function(err,res)) 中有一个额外的),但最后您缺少})

这是您的代码,没有语法错误。

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

【讨论】:

  • 请原谅愚蠢的错误..我还有一个错误,你可以请 module.js:328 throw err; ^ 为什么会这样?
  • 嗯,发布完整的堆栈跟踪,它在第 328 行,您这里只有 8 个,所以,发布更多代码或完整的堆栈跟踪。
  • 我已经添加了完整的错误日志。你能在上面检查一下吗?请帮忙?
  • 我会在大约 6 小时后回家看看 :)。但是现在您的插件本身似乎有一个错误,我可能需要知道您是如何构建它的,也许可以发布您的binding.gyp 以便我了解更多信息,并且能够自己编译插件。
  • 谢谢我从错误的路径构建它现在我有运行时错误。我已经发布了新问题stackoverflow.com/questions/49758230/…
猜你喜欢
  • 2012-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-03
  • 2019-08-02
  • 1970-01-01
  • 1970-01-01
  • 2017-06-02
相关资源
最近更新 更多