title: How to access exported "nested" functions in Nodejs - TypeError: is not a function
body: <p>This is a case of exported nested modules:</p>
  
  <h2>BaseTutorial.js</h2>
  
  <pre><code>// exports module makes the functions public such that they can be accessed in other modules in Node.js.
  module.exports.fun_tutorial = function()
  {
      console.log("First print from Tutorial.js")                                
  }
  </code></pre>
  
  <h2>Extended_NodeTutorial.js</h2>
  
  <pre><code>    // `require` is the way to include other modules in
  
  var obj_baseTutorialJS = require('./Base_Tutorial.js');
  
  module.exports.fun_extendedNodeTutorial = function()
  {
      console.log("Second print from Extended_NodeTutorial.js")
  
      this.ss = function fun_nested()         
      {
          console.log("sadasdsa")
          var fun_nested = obj_baseTutorialJS
          fun_nested.fun_tutorial();
      }
  }
  </code></pre>
  
  <h2>app.js</h2>
  
  <pre><code>var obj_extendedNodeTutorial = require('./Extended_NodeTutorial.js');
  console.log(obj_extendedNodeTutorial)
  
  obj_extendedNodeTutorial.fun_extendedNodeTutorial();
  obj_extendedNodeTutorial.fun_extendedNodeTutorial.fun_nested();
  </code></pre>
  
  <h2>Error after executing <code>node app.js</code>:</h2>
  
  <pre><code>{ fun_extendedNodeTutorial: [Function] }
  Second print from Extended_NodeTutorial.js
  /home/***/Documents/home_notes/MEAN/app.js:7
  obj_extendedNodeTutorial.fun_extendedNodeTutorial.fun_nested();
                                                    ^
  
  TypeError: obj_extendedNodeTutorial.fun_extendedNodeTutorial.fun_nested is not a function
      at Object.&lt;anonymous&gt; (/home/***/Documents/home_notes/MEAN/app.js:7:51)
      at Module._compile (module.js:569:30)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:503:32)
      at tryModuleLoad (module.js:466:12)
      at Function.Module._load (module.js:458:3)
      at Function.Module.runMain (module.js:605:10)
      at startup (bootstrap_node.js:158:16)
      at bootstrap_node.js:575:3
  </code></pre>
  
  <hr>