title: nodejs c++ addon -- unable to node-gyp build using nan module
body: <p>I am learning how to build C/C++ addons for nodejs.</p>
  
  <p>I could successfully node-gyp configure, node-gyp build and run node index.js on a simple hellow world program.  So, my basic setup is working. The below code (copy-paste from official nodejs documentation) is the working version of my C++ code.</p>
  
  <pre><code>//hello.cc
  //#include &lt;node.h&gt;
  //#include &lt;nan.h&gt;
  #include "./node_modules/nan/nan.h"
  #include &lt;iostream&gt; 
  using namespace v8;
  
  namespace demo {
    using v8::FunctionCallbackInfo;
    using v8::Isolate;
    using v8::Local;
    using v8::Object;
    using v8::String;
    using v8::Value;
  
    void Method (const FunctionCallbackInfo&lt;Value&gt;&amp; args) {
      Isolate* isolate = args.GetIsolate();
      std::cout &lt;&lt; "Executing some stupid func..." &lt;&lt; std::endl;    
      args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
    }
  
    void init(Local&lt;Object&gt; exports) {
      NODE_SET_METHOD(exports, "hello", Method);
    }
  
    NODE_MODULE(addon, init)
  } // namespace demo
  </code></pre>
  
  <p>However, when I use <strong>Nan</strong> module, and the version of code documented in the nan site, I get compilation errors indicating NanScope is not declared in this scope.</p>
  
  <pre><code>//hello.cc
  #include "./node_modules/nan/nan.h"
  #include &lt;iostream&gt; 
  using namespace v8;
  
    NAN_METHOD(Method) {
            Nan::NanScope();
      NanReturnValue(String::New("world"));
    }
  
    void init(Handle&lt;Object&gt; exports) {
      exports-&gt;Set(NanSymbol("hello"), 
          FunctionTemplate::New(Method)-&gt;GetFunction());
    }
  
    NODE_MODULE(hello, init)
  </code></pre>
  
  <p>Part of the error output...</p>
  
  <pre><code>make: Entering directory '/home/rvnath/projects/comviva/node-addons/hello-world/build'
    CXX(target) Release/obj.target/addon/hello1.o
  ../hello1.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE Method(Nan::NAN_METHOD_ARGS_TYPE)’:
  ../hello1.cc:7:14: error: ‘NanScope’ was not declared in this scope
       NanScope();
                ^
  </code></pre>
  
  <p>After a bit of googling around, a few sites pointed out that we should be using Nan::Scope, and that the Nan documentation was out-of-date.  I tried the change but it still didn't work.  It gives an error saying "Scope is not a member of Nan".</p>
  
  <p>I am unable to find, how to use the Nan version correctly.  Any help here will be highly appreciated.</p>