C++ 尝试创建节点本机加载项时出错\u DLOPEN\u
我试图制作一个节点本机插件,并且C++ 尝试创建节点本机加载项时出错\u DLOPEN\u,c++,node.js,node-gyp,C++,Node.js,Node Gyp,我试图制作一个节点本机插件,并且node gyp configure build工作正常,当时我需要一个javascript文件中的测试插件,并使用node main正常运行,然后给出错误error:Module未自注册,code:ERR\u DLOPEN\u失败这是我目前为止的代码: binding.gyp { "targets": [ { "target_name": "hello",
node gyp configure build
工作正常,当时我需要一个javascript文件中的测试插件,并使用node main
正常运行,然后给出错误error:Module未自注册,code:ERR\u DLOPEN\u失败
这是我目前为止的代码:
binding.gyp
{
"targets": [
{
"target_name": "hello",
"source": ["hello.cc"]
}
]
}
你好,cc
#include <node/node.h>
#include <node/v8.h>
using namespace v8;
void Method(const FunctionCallbackInfo<Value>&args) {
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world").ToLocalChecked());
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize);
如何修复此错误?谢谢
const hello = require("./build/Release/hello");
console.log(hello.hello())