Error: The specified module could not be found. Node-gyp compiled module

So i’m working on a Flight Simulator add-on and as you probably know the sdk is only available in C++ and C#. The problem is that i’m working on the UI with Javascript and NodeJS. I’m currenlty blocked on a bug that I don’t know how to fix. So basically I’ve downloaded the “node-gyp” package to be able to run C++ code directly into my NodeJS program, and the app isn’t working due to what I thing missing dependencies, here is my code :

portal.js

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const simConnect = require('./build/Release/simconnect');
function onSimulatorStart() {
console.log('Simulator has started!');
}
simConnect.initializeSimConnect(onSimulatorStart);
</code>
<code>const simConnect = require('./build/Release/simconnect'); function onSimulatorStart() { console.log('Simulator has started!'); } simConnect.initializeSimConnect(onSimulatorStart); </code>
const simConnect = require('./build/Release/simconnect');

function onSimulatorStart() {
    console.log('Simulator has started!');
}

simConnect.initializeSimConnect(onSimulatorStart);

simconnect.cpp

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#include <node.h>
#include <windows.h>
#include <SimConnect.h>
#include <iostream>
#include <thread>
using namespace v8;
HANDLE hSimConnect = NULL;
Persistent<Function> callback;
enum EVENT_ID {
EVENT_SIM_START
};
void onSimulatorStart();
void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext) {
if (pData->dwID == SIMCONNECT_RECV_ID_EVENT) {
SIMCONNECT_RECV_EVENT* evt = (SIMCONNECT_RECV_EVENT*)pData;
if (evt->uEventID == EVENT_SIM_START) {
onSimulatorStart();
}
}
}
void onSimulatorStart() {
Isolate* isolate = Isolate::GetCurrent();
HandleScope handleScope(isolate);
Local<Function> cb = Local<Function>::New(isolate, callback);
cb->Call(isolate->GetCurrentContext(), Null(isolate), 0, nullptr).ToLocalChecked();
}
void InitializeSimConnect(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Callback must be a function").ToLocalChecked()));
return;
}
Local<Function> cb = Local<Function>::Cast(args[0]);
callback.Reset(isolate, cb);
if (SUCCEEDED(SimConnect_Open(&hSimConnect, "SimConnect Test", NULL, 0, 0, 0))) {
std::cout << "Connected to Flight Simulator!" << std::endl;
SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");
std::thread([]() {
while (true) {
SimConnect_CallDispatch(hSimConnect, MyDispatchProcRD, NULL);
Sleep(1);
}
}).detach();
} else {
isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, "Unable to connect to Flight Simulator").ToLocalChecked()));
}
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "initializeSimConnect", InitializeSimConnect);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
</code>
<code>#include <node.h> #include <windows.h> #include <SimConnect.h> #include <iostream> #include <thread> using namespace v8; HANDLE hSimConnect = NULL; Persistent<Function> callback; enum EVENT_ID { EVENT_SIM_START }; void onSimulatorStart(); void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext) { if (pData->dwID == SIMCONNECT_RECV_ID_EVENT) { SIMCONNECT_RECV_EVENT* evt = (SIMCONNECT_RECV_EVENT*)pData; if (evt->uEventID == EVENT_SIM_START) { onSimulatorStart(); } } } void onSimulatorStart() { Isolate* isolate = Isolate::GetCurrent(); HandleScope handleScope(isolate); Local<Function> cb = Local<Function>::New(isolate, callback); cb->Call(isolate->GetCurrentContext(), Null(isolate), 0, nullptr).ToLocalChecked(); } void InitializeSimConnect(const FunctionCallbackInfo<Value>& args) { Isolate* isolate = args.GetIsolate(); if (!args[0]->IsFunction()) { isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Callback must be a function").ToLocalChecked())); return; } Local<Function> cb = Local<Function>::Cast(args[0]); callback.Reset(isolate, cb); if (SUCCEEDED(SimConnect_Open(&hSimConnect, "SimConnect Test", NULL, 0, 0, 0))) { std::cout << "Connected to Flight Simulator!" << std::endl; SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart"); std::thread([]() { while (true) { SimConnect_CallDispatch(hSimConnect, MyDispatchProcRD, NULL); Sleep(1); } }).detach(); } else { isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, "Unable to connect to Flight Simulator").ToLocalChecked())); } } void Initialize(Local<Object> exports) { NODE_SET_METHOD(exports, "initializeSimConnect", InitializeSimConnect); } NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) </code>
#include <node.h>
#include <windows.h>
#include <SimConnect.h>
#include <iostream>
#include <thread>

using namespace v8;

HANDLE hSimConnect = NULL;
Persistent<Function> callback;

enum EVENT_ID {
    EVENT_SIM_START
};

void onSimulatorStart();

void CALLBACK MyDispatchProcRD(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext) {
    if (pData->dwID == SIMCONNECT_RECV_ID_EVENT) {
        SIMCONNECT_RECV_EVENT* evt = (SIMCONNECT_RECV_EVENT*)pData;
        if (evt->uEventID == EVENT_SIM_START) {
            onSimulatorStart();
        }
    }
}

void onSimulatorStart() {
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope handleScope(isolate);

    Local<Function> cb = Local<Function>::New(isolate, callback);
    cb->Call(isolate->GetCurrentContext(), Null(isolate), 0, nullptr).ToLocalChecked();
}

void InitializeSimConnect(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = args.GetIsolate();

    if (!args[0]->IsFunction()) {
        isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Callback must be a function").ToLocalChecked()));
        return;
    }

    Local<Function> cb = Local<Function>::Cast(args[0]);
    callback.Reset(isolate, cb);

    if (SUCCEEDED(SimConnect_Open(&hSimConnect, "SimConnect Test", NULL, 0, 0, 0))) {
        std::cout << "Connected to Flight Simulator!" << std::endl;
        SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");

        std::thread([]() {
            while (true) {
                SimConnect_CallDispatch(hSimConnect, MyDispatchProcRD, NULL);
                Sleep(1);
            }
        }).detach();
    } else {
        isolate->ThrowException(Exception::Error(String::NewFromUtf8(isolate, "Unable to connect to Flight Simulator").ToLocalChecked()));
    }
}

void Initialize(Local<Object> exports) {
    NODE_SET_METHOD(exports, "initializeSimConnect", InitializeSimConnect);
}

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)

binding.gyp

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"targets" : [
{
"include_dirs": [
"./include"
],
"libraries": [
"../lib/SimConnect.lib"
],
"defines": [
"NAPI_DISABLE_CPP_EXCEPTIONS"
],
"target_name" : "simconnect",
"sources" : [ "src/simconnect.cpp" ]
}
]
}
</code>
<code>{ "targets" : [ { "include_dirs": [ "./include" ], "libraries": [ "../lib/SimConnect.lib" ], "defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ], "target_name" : "simconnect", "sources" : [ "src/simconnect.cpp" ] } ] } </code>
{
    "targets" : [
        {
            "include_dirs": [
                "./include"
            ],
            "libraries": [
                "../lib/SimConnect.lib"
            ],
            "defines": [
                "NAPI_DISABLE_CPP_EXCEPTIONS"
            ],
            "target_name" : "simconnect",
            "sources" : [ "src/simconnect.cpp" ]
        }
    ]
}

after every modifications, I run those commands :
node-gyp clean
node-gyp configure
node-gyp build

after the build, there is no errors.

So when I start my program I get this error :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>> [email protected] start
> electron . --enable-logging
App threw an error during load
Error: The specified module could not be found.
\?C:UsersblutiDocumentsFlightCareerbuildReleasesimconnect.node
at process.func [as dlopen] (node:electron/js2c/node_init:2:2214)
at Module._extensions..node (node:internal/modules/cjs/loader:1489:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2214)
at Module.load (node:internal/modules/cjs/loader:1214:32)
at Module._load (node:internal/modules/cjs/loader:1030:12)
at c._load (node:electron/js2c/node_init:2:13672)
at Module.require (node:internal/modules/cjs/loader:1242:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (C:UsersblutiDocumentsFlightCareerportal.js:1:20)
at Module._compile (node:internal/modules/cjs/loader:1391:14)
</code>
<code>> [email protected] start > electron . --enable-logging App threw an error during load Error: The specified module could not be found. \?C:UsersblutiDocumentsFlightCareerbuildReleasesimconnect.node at process.func [as dlopen] (node:electron/js2c/node_init:2:2214) at Module._extensions..node (node:internal/modules/cjs/loader:1489:18) at Object.func [as .node] (node:electron/js2c/node_init:2:2214) at Module.load (node:internal/modules/cjs/loader:1214:32) at Module._load (node:internal/modules/cjs/loader:1030:12) at c._load (node:electron/js2c/node_init:2:13672) at Module.require (node:internal/modules/cjs/loader:1242:19) at require (node:internal/modules/helpers:176:18) at Object.<anonymous> (C:UsersblutiDocumentsFlightCareerportal.js:1:20) at Module._compile (node:internal/modules/cjs/loader:1391:14) </code>
> [email protected] start
> electron . --enable-logging


App threw an error during load
Error: The specified module could not be found.
\?C:UsersblutiDocumentsFlightCareerbuildReleasesimconnect.node
    at process.func [as dlopen] (node:electron/js2c/node_init:2:2214)
    at Module._extensions..node (node:internal/modules/cjs/loader:1489:18)
    at Object.func [as .node] (node:electron/js2c/node_init:2:2214)
    at Module.load (node:internal/modules/cjs/loader:1214:32)
    at Module._load (node:internal/modules/cjs/loader:1030:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at Module.require (node:internal/modules/cjs/loader:1242:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:UsersblutiDocumentsFlightCareerportal.js:1:20)
    at Module._compile (node:internal/modules/cjs/loader:1391:14)

So, what I know is that the ‘portal.js’ can without any problem found the ‘simconnect.node’ file by the module ‘simconnect’ seems to doesn’t find another module. Thanks for reading this and for replying me if you have a solution !

Install Cmake, check my architecture, delete node modules folder and reimport dependencies, type full path of libraries and includes files

New contributor

Sébastien Técher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật