Hey.
So since a while now, I have tried my luck with nodejs modules - especially native addons. It turns out that those are nothing but dynamic libraries (well lol, who would have guessed?).
In order to implement support for these in nexe, one would have to either fake the dlopen function and point it BACK at the executable. Buuuut, that may be no good idea entirely... So I got another idea.
Since nodejs does not offer a real way to do manual memory management, and hence can not read binary data off memory, or require() it from there, there is the option to dynamicaly extract the shared objects, and then require them. That is, if we have no other choice.
But if you find a way to place the .node file into meory and trick require in reading it, then you would get what you want.
In PHP, one can use stream wrappers to do that. I dont know is there is such a way for nodejs though.
But I thought I would share my opinion and thought on this, as I am needing this functionality myself currently o.o
Kind regards, Ingwie
Seems like the only way to do this is to embed native modules into the Node.js application. I plan to implement this sometime - just haven't gotten around to it yet.
Far back, I have published a tutorial on the nodejs mailing list, explaining how a native module can be compiled into the binary, and then be used. The procedure is really simple:
Embedded JS fields are required by their basename. So, mymodule.js becomes require(„mymodule“).
Native modules must start with node_ - otherwise, they won’t bind. Example: node_mymodule. Then use process.bind(„mymodule“) to access it.
Thats the short and rough info, maybe you can use some info from that for working ont his issue :)
Kind regards, Ingwie.
Am Fr. Feb. 28 2014 19:31:12 schrieb Craig Condon:
Seems like the only way to do this is to embed native modules into the Node.js application. I plan to implement this sometime - just haven't gotten around to it yet.
—
Reply to this email directly or view it on GitHub.
:+1:
Implemented with nexe@beta
Native modules (.node) and friends (.dll) can be bundled and will be written at runtime. alongside the binary. Doing this from memory was impractical as it would require forking node and performing some shady stuff with the filesystem to get in-memory linking.
see examples/native-build
@calebboyd What happened to native module support and the native-build example?
Most helpful comment
@calebboyd What happened to native module support and the native-build example?