You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ImanCol , it is not clear from the issue description what you are trying to do and how to reproduce the issue.
Thus, it is not actionable and it is difficult to help you.
Could you please,
State what you are trying to do
What is the issue that you see
Provide the steps to reproduce the failing scenario
In case if you see an issue with the microsoft/node-api-dotnet project, then please create an issue against that project and I will be glad to help you there.
@ImanCol , it is not clear from the issue description what you are trying to do and how to reproduce the issue. Thus, it is not actionable and it is difficult to help you. Could you please,
State what you are trying to do
What is the issue that you see
Provide the steps to reproduce the failing scenario
In case if you see an issue with the microsoft/node-api-dotnet project, then please create an issue against that project and I will be glad to help you there.
Oh, sorry, I've been reviewing several .NET projects based on Wrapp NodeLib, and I don't know how I got to this one.
Perhaps I should even open the issue in the three most well-known bridges (Tencent/puerts, agracio/edge-js, Microsoft/node-api-dotne), or maybe just one in a central repository and mention all three.
I should clarify that libnode in the three projects mentioned works fine with node.exe, whether from metacall/libnode or alshdavid/libnode-prebuilt for Windows compilation.
What's the problem I'm having?
Mainly, I can't load "nodes_modules" containing native .node or .bare files in these Wrapp .NET libnode projects. They immediately throw an exception or close (see the log files I sent).
How to reproduce the problem?
Just look for any native C++ library that works like nodes_modules (.node, .bare) or that depends on them (e.g., udx_native, sodium-native, keypear). Try referencing it in your main.js file, which will then be called in the C# script, using any libnode .NET wrapper.
Does it load the NodeJS modules without problems?
No.
I've already opened a support issue for the "official" PuerTS example, but they refused to provide support.
Thanks! I cannot say much about other projects, but I will investigate the issue inside of the Microsoft code since I am one of the contributors there.
Great! Sorry, I will not be able to download your zip file.
Giving a reference to some temporary repo usually works better.
I assume I do not need the full unity context to see the issue.
Which platform do you use? Windows? Linux?
I guess the main issue is that each .node file expects Node-API functions to be exported from the executable file that you run.
In case of libnode.dll these functions are exported from the DLL.
The process must somehow re-export them in order to load .node extensions.
If the process is your own then I would expect it can be done through a specially crafted .def file.
In case if the process cannot be changed like with the ASP.NET server, then the problem becomes a bit more interesting.
Just to find out why it was preventing me from loading libraries, I tried some other examples based on the DotNet Project (outside of Unity). Almost all of them gave me the same error: the application crashed when it tried to load them. I read somewhere that it might be related to CoreCLR (not yet implemented in Unity), but I don't know much about it. I only focus on the game engine, and the simple fact of having to compile such modules to be compatible sounds difficult to me, so I'm leaving this to someone with more experience because without any examples, I don't know what to do.
I'm only using Windows for now, but I want to make it work on Android, so the approach of using NodeJs as a process won't work. Therefore, I'll compile my game on Android with libnode when the modules don't crash the application.
@ImanCol , this is what I found so far:
Similar issue was reported before: nodejs/node#47682
Then, it was fixed in node-gyp and Node.js code in nodejs/node-gyp#2834
Any .node module compiled by node-gyp (used by Node.js by default) is also linking the code from the src/win_delay_load_hook.cc.
The issue can be resolved by either changing the cmake-napi to provide libnode.dll-compatible version of delay-load.c, or you should consider a different module for your needs. Currently these .node modules cannot work with libnode.dll regardless if you use any .Net framework binding or not.
Oh, that's incredible. Give me some time to familiarize myself with CMake, and maybe I'll let the developers know if they'll provide support. I'll let you know here if anything changes. On another note, I'm glad LibNode supports .node, but to confirm, I'd like to try a native library that's already supported to see if my script doesn't encounter any errors (I'd even try it in PuerTS or EdgeJS).
I have partially solved this by replacing native libraries with .NET libraries using stub objects
That way I don't have to worry about recompiling them (except for libnode and PuerTS) on different platforms, Unity will do it for me.
I'm sorry if this doesn't help anyone, I preferred this personal benefit.
Activity
vmoroz commentedon Nov 21, 2025
@ImanCol , it is not clear from the issue description what you are trying to do and how to reproduce the issue.
Thus, it is not actionable and it is difficult to help you.
Could you please,
In case if you see an issue with the
microsoft/node-api-dotnetproject, then please create an issue against that project and I will be glad to help you there.Naminave commentedon Nov 21, 2025
Oh, sorry, I've been reviewing several .NET projects based on Wrapp NodeLib, and I don't know how I got to this one.
Perhaps I should even open the issue in the three most well-known bridges (Tencent/puerts, agracio/edge-js, Microsoft/node-api-dotne), or maybe just one in a central repository and mention all three.
I should clarify that libnode in the three projects mentioned works fine with node.exe, whether from metacall/libnode or alshdavid/libnode-prebuilt for Windows compilation.
What's the problem I'm having?
Mainly, I can't load "nodes_modules" containing native .node or .bare files in these Wrapp .NET libnode projects. They immediately throw an exception or close (see the log files I sent).
How to reproduce the problem?
Just look for any native C++ library that works like nodes_modules (.node, .bare) or that depends on them (e.g., udx_native, sodium-native, keypear). Try referencing it in your main.js file, which will then be called in the C# script, using any libnode .NET wrapper.
Does it load the NodeJS modules without problems?
No.
I've already opened a support issue for the "official" PuerTS example, but they refused to provide support.
What's the point of allowing nodes_modules in these wrappers if most of them won't work?
zombieyang/puerts-ts-loader#19 (comment)
vmoroz commentedon Nov 21, 2025
Thanks! I cannot say much about other projects, but I will investigate the issue inside of the Microsoft code since I am one of the contributors there.
Naminave commentedon Nov 21, 2025
Oh, great, thanks. I also want to mention that I'm trying to use it in Unity. Here are some examples.
Microsoft NodeApi Unity.zip
vmoroz commentedon Nov 21, 2025
Great! Sorry, I will not be able to download your zip file.
Giving a reference to some temporary repo usually works better.
I assume I do not need the full unity context to see the issue.
Which platform do you use? Windows? Linux?
I guess the main issue is that each .node file expects Node-API functions to be exported from the executable file that you run.
In case of libnode.dll these functions are exported from the DLL.
The process must somehow re-export them in order to load .node extensions.
If the process is your own then I would expect it can be done through a specially crafted .def file.
In case if the process cannot be changed like with the ASP.NET server, then the problem becomes a bit more interesting.
Naminave commentedon Nov 22, 2025
I uploaded it to Gist.
https://gist.github.com/ImanCol/eec07bae53020dbac2bd093ddb884592
Just to find out why it was preventing me from loading libraries, I tried some other examples based on the DotNet Project (outside of Unity). Almost all of them gave me the same error: the application crashed when it tried to load them. I read somewhere that it might be related to CoreCLR (not yet implemented in Unity), but I don't know much about it. I only focus on the game engine, and the simple fact of having to compile such modules to be compatible sounds difficult to me, so I'm leaving this to someone with more experience because without any examples, I don't know what to do.
Naminave commentedon Nov 22, 2025
I'm only using Windows for now, but I want to make it work on Android, so the approach of using NodeJs as a process won't work. Therefore, I'll compile my game on Android with libnode when the modules don't crash the application.
vmoroz commentedon Nov 23, 2025
@ImanCol , this is what I found so far:
Similar issue was reported before: nodejs/node#47682
Then, it was fixed in node-gyp and Node.js code in nodejs/node-gyp#2834
Any .node module compiled by node-gyp (used by Node.js by default) is also linking the code from the src/win_delay_load_hook.cc.
The issue with the .node modules that you had referenced is that they have their own version of that file that is not compatible with the
libnode.dllsupport: https://github.com/holepunchto/cmake-napi/blob/main/win32/delay-load.c.The issue can be resolved by either changing the
cmake-napito providelibnode.dll-compatible version ofdelay-load.c, or you should consider a different module for your needs. Currently these .node modules cannot work withlibnode.dllregardless if you use any .Net framework binding or not.Naminave commentedon Nov 24, 2025
Oh, that's incredible. Give me some time to familiarize myself with CMake, and maybe I'll let the developers know if they'll provide support. I'll let you know here if anything changes. On another note, I'm glad LibNode supports .node, but to confirm, I'd like to try a native library that's already supported to see if my script doesn't encounter any errors (I'd even try it in PuerTS or EdgeJS).
Naminave commentedon Dec 11, 2025
I have partially solved this by replacing native libraries with .NET libraries using stub objects
That way I don't have to worry about recompiling them (except for libnode and PuerTS) on different platforms, Unity will do it for me.
I'm sorry if this doesn't help anyone, I preferred this personal benefit.