Trying to make Hello World native module for node.js
Got an Win32 Project in VS 2012 with one file:
#include <node.h>
#include <v8.h>
using namespace v8;
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
return scope.Close(String::New("world"));
}
void init(Handle<Object> target) {
target->Set(String::NewSymbol("hello"),
FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(hello, init)
That`s compiles to hello.node.
Options:
- Dynamic Library (.dll)
- No Common Language Runtime Support
Use it like:
hello = require './hello'
console.log hello.hello()
It works on local machine (win8 x64, node: 0.8.12)
But on remote server (windows server 2008 x64, node: 0.8.12, iisnode: 0.1.21 x64, iis7) it throws this error:
Application has thrown an uncaught exception and is terminated: Error:
%1 is not a valid Win32 application.C:\inetpub\test\lib\server\hello.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)
at Object. (C:\inetpub\test\lib\server\index.js:32:9)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
What I tried:
Playing with app pool settings (enable win32 apps) does not helped.
Iisnode x86 does not install on x64 OS.
Can`t compile to x64 because of error: Error 2 error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' C:\derby\hello\build\node.lib(node.exe) hello
Does anyone have any suggestions?