"The specified module could not be found." when copying project with native addon to server machine

I created a native addon for node, a 64bit dll, compiled with the /clr flag to access another .net dll.

All works nicely on my development box (Windows 7, 64bit), but when copying the whole directory over to a server box (Windows Server 2008 R2, 64bit, .net 4.0 Client Profile & Extended installed), a

var myaddon = require('./build/Release/myaddon');

yields the following error:

module.js:485
  process.dlopen(filename, module.exports);
          ^
Error: The specified module could not be found.
C:\Users\x\build\Release\myaddon.node
    at Object.Module._extensions..node (module.js:485:11)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)

I know it successfully finds the file 'myaddon.node', because when I change the require statement slightly to point to a non-existing file, it will complain with a different error message.

Without my require statement, node starts up fine.

Why the error and how to fix it?

After starting a plugin from scratch for debugging purposes without /clr - which worked fine - I figured it out.

  • Setting the '/clr' flag forces you to change '/MT' (static linking of runtime libs) to '/MD' (dynamic linking of rt libs)
  • dynamic linking means the C++ dlls need to be installed on the target machine

In my case that meant installing Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) on the server.