Estaba intentando hacer un complemento nativo de nodo y node-gyp configure build funcionó bien, cuando necesité el complemento de prueba en un archivo javascript y lo ejecuté normalmente con node main , luego aparece el error Error: Module did not self register, code: ERR_DLOPEN_FAILED aquí está mi código hasta ahora:
encuadernación.gyp
{ "targets": [ { "target_name": "hello", "source": ["hello.cc"] } ] }hola.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);principal.js
const hello = require("./build/Release/hello"); console.log(hello.hello())¿Cómo soluciono este error? Gracias.
Puede verificar qué versión del nodo está usando nvm ls (para enumerar las versiones del nodo)
intente cambiar la versión del nodo para verificar y ejecutar el comando nuevamente nvm use version_number (para cambiar la versión)