Node.js native module is not a valid Win32 application error

前端 未结 4 1744
庸人自扰
庸人自扰 2021-02-07 05:11

Trying to make Hello World native module for node.js

Got an Win32 Project in VS 2012 with one file:

#include 

        
4条回答
  •  一向
    一向 (楼主)
    2021-02-07 05:57

    I dont know if it's too late, but I found the answer after some trial and error, mainly the problem (in my machine) was that I compiled the nodejs on windows to be able to create the extension using visual C++, and I already had installed the nodejs from the page, if I try to run the test using the default installation (which was added to my PATH by the nodejs installer) then it fails, but if I use the compiled node.exe (the one I compiled to be able to reference the libs in Visual C++) then it works.

    In summary, the problem is not with the extension, it's with the nodejs compilation, use the node that you compiled (in order to build the VS solution I assume you did that) and then it should work on the remote machine.

    Note: The problem relies on that you're using node.exe compiled in 64bits to run a 32bits dll, that's why it's complaining, if you use node.exe in 32 bits it should work. (at least that solved my problem)

提交回复
热议问题