[英]NodeJS and N-API
我正在嘗試編譯和使用N-API Node JS c ++插件。 代碼可以正常編譯,但在運行時出現以下錯誤:
module.js:664
return process.dlopen(module, path._makeLong(filename));
^
Error: Module did not self-register.
at Object.Module._extensions..node (module.js:664:18)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/johngorter/Desktop/WASM/index2.js:1:77)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
奇怪的是,當我用“普通的” C ++附加代碼(沒有N-API)替換cc代碼時,一切正常。
我正在使用NodeJS 8.9.2。
有人有線索嗎?
TIA,約翰。
您缺少一些看起來像這樣的代碼,這些代碼需要注冊在JavsScript中可用的功能。
Napi::Object Init( Napi::Env env, Napi::Object exports )
{
exports.Set(
Napi::String::New( env, "someFunctionName"),
Napi::Function::New( env, someFunctionName)
);
exports.Set(
Napi::String::New( env, "someOtherFunctionName"),
Napi::Function::New( env, someOtherFunctionName)
);
return exports;
}
NODE_API_MODULE( yourModuleName, Init );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.