title: How to create native module for node.js
body: <p>I want to create my own native Nodejs module. I have been following <a href="http://nodejs.org/docs/latest/api/addons.html" rel="nofollow">http://nodejs.org/docs/latest/api/addons.html</a>  and try to understand how to create native module .</p>
  
  <p>First created hello.cc </p>
  
  <pre><code>#include &lt;node.h&gt;
  #include &lt;v8.h&gt;
  using namespace v8;
  Handle&lt;Value&gt; Method(const Arguments&amp; args) {
   HandleScope scope;
   return scope.Close(String::New("world"));
  }
  
  void init(Handle&lt;Object&gt; exports) {
    exports-&gt;Set(String::NewSymbol("hello"),
    FunctionTemplate::New(Method)-&gt;GetFunction());
  }
  
      NODE_MODULE(hello, init)
  </code></pre>
  
  <p>Then created binding.gyp</p>
  
  <pre><code> {
     "targets": [
     {
       "target_name": "hello",
       "sources": [ "hello.cc" ]
     }
    ]
   }
  </code></pre>
  
  <p>Then I ran these command </p>
  
  <pre><code>node-gyp configure
  node-gyp build
  </code></pre>
  
  <p>finally created hello.js </p>
  
  <pre><code>     var addon = require('./build/Release/hello');
        console.log(addon.hello()); 
  </code></pre>
  
  <p>At this time I got error like</p>
  
  <pre><code> module.js:355
   Module._extensions[extension](this, filename);
  </code></pre>
  
  <p>and so on.</p>