Thursday, December 15, 2011

Debugging native node modules loading failure on windows

If you ever need to build a module that requires another library (e.g. openssl, ict, expat etc) you may receive an “Out of memory” error when you require the file. This is unfortunately a generic error on windows but you can fire up visual studio and debug node (attaching to a process) and you can can see there the exact system error number (sys_errno) by adding a breakpoint in deps\uv\src\win\error.c when uv translates the error code (uv_translate_sys_error).

In my case I was receiving the 126 error code which I looked up at http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx and then I figured that I hadn’t restarted the console after I added the referring dll file path in my enviroment PATH variable… I opened a new console, verified that the dll’s path is in my PATH variable and the module loaded just fine…

Hope this helps a bit when you try to debug weird loading errors.

0 comments: