Module did not self-register for edge_nativeclr.node | code: 'ERR_DLOPEN_FAILED' with Node 18
kakkar17 opened this issue · comments
Issue: Module did not self-register for edge_nativeclr.node | code: 'ERR_DLOPEN_FAILED' with Node 18
Error:
Error: Module did not self-register: '\\?\C:\projects\edge-js\lib\native\win32\x64\18.4.0\edge_nativeclr.node'.
at Module._extensions..node (node:internal/modules/cjs/loader:1203:18)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12)
at Module.require (node:internal/modules/cjs/loader:1021:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\projects\edge-js\lib\edge.js:52:8)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12) {
code: 'ERR_DLOPEN_FAILED'
}
The same error is happening here for Node 18 in this CI run: https://ci.appveyor.com/project/agracio/edge-js/builds/44772581/job/uyvrmskvw2tac57a
If anyone is facing this error, please find the below resolution.
Resolution:
This needed to build your own binaries for your specific node version.
In this below case, I tested out with Node 18.9.0
Step 1:
Upgrade nan to latest 2.16.0 (https://www.npmjs.com/package/nan)
ref:
Line 40 in c1cfba1
Step 2:
Change this NODE_MODULE
initialization to NAN_MODULE_WORKER_ENABLED
ref:
Lines 84 to 86 in c1cfba1
-->
#if NODE_MAJOR_VERSION >= 10
NAN_MODULE_WORKER_ENABLED(edge_coreclr, init)
#else
NODE_MODULE(edge_coreclr, init)
#endif
#else
#if NODE_MAJOR_VERSION >= 10
NAN_MODULE_WORKER_ENABLED(edge_nativeclr, init)
#else
NODE_MODULE(edge_nativeclr, init)
#endif
or
NAN_MODULE_WORKER_ENABLED(edge_coreclr, init)
#else
NAN_MODULE_WORKER_ENABLED(edge_nativeclr, init)
Step 3:
Change this to your targeted node version. In my case, it's 18.9.0
Line 9 in c1cfba1
Step 4:
Build it with the targeted node version (ex: 18.9.0)
The new edge_nativeclr.node
will not have the above issue and works fine with the node 18.9.0
@agracio - Can you please build this above for node 18.9.0? So that, we do not have to create/build separate binaries for this issue.
Thanks in the advance!
Updated and published to npm.