title: NodeJS TypeError: Cannot read property of undefined
body: <p>so I just started using NodeJs still have a lot to learn but am loving it so far I ran into this problem I found an answer, but it's not what I want it's kinda weird, let me show some code and explain</p>
  
  <p>So I got 2 files</p>
  
  <p>File 1 > app.js (Main)</p>
  
  <p>File 2 > UserEntity.js (Module)</p>
  
  <p>app.js:</p>
  
  <pre><code>var uEntity = require('./UserEntity.js');
  
  var hm = new uEntity.person();
  console.log(hm.info.strUsername);
  </code></pre>
  
  <p>UserEntity.js:</p>
  
  <pre><code>function User() {
      this.info = {
          'strUsername': 'Hashimoro'
      };
  }
  
  module.exports.person = User;
  </code></pre>
  
  <p>I am creating a new UserEntity I want to access the info directly as you can see from the code</p>
  
  <p>But it gives this error:</p>
  
  <pre><code>console.log(hm.info.strUsername);
                     ^
  
  TypeError: Cannot read property 'strUsername' of undefined
      at Object.&lt;anonymous&gt; (D:\NodeLearn\Testing\app.js:4:20)
      at Module._compile (module.js:570:32)
      at Object.Module._extensions..js (module.js:579:10)
      at Module.load (module.js:487:32)
      at tryModuleLoad (module.js:446:12)
      at Function.Module._load (module.js:438:3)
      at Module.runMain (module.js:604:10)
      at run (bootstrap_node.js:394:7)
      at startup (bootstrap_node.js:149:9)
      at bootstrap_node.js:509:3
  </code></pre>
  
  <p>If someone can give a fix and explain would be great</p>
  
  <p>Thank you, seriously appreciate it</p>