title: Accessing function from exported module (node.js)
body: <p>I have been reading up on this and apprently there are more ways to export a module in node.js.</p>
  
  <p>One of the simple things you can do with modules is to encapsulate functions within a file like so:</p>
  
  <pre><code>module.exports = {
    sayHelloInEnglish: function() {
      return "HELLO";
    },
  
    sayHelloInSpanish: function() {
      return "Hola";
    }
  };
  </code></pre>
  
  <p>However i would like to create some more dirverse modules and so ive created the following user module:</p>
  
  <pre><code>    var UserModule = function (socket) {
      var userList = [];
  
      socket.on('userData', function (userDetails) {
          userDetails.socket = socket;
          userList[userDetails.id] = userDetails
      });
  
      socket.on('getActiveUsers', function () {
          socket.emit('activeUsers', userList);
      });
  
      function helloWorld (){
          console.log('hello world');
      }
  
  };
  
  module.exports = function (socket) {
      return new UserModule(socket);
  };
  </code></pre>
  
  <p>now i am requireing this module in my io instance:</p>
  
  <pre><code>    io.on('connection', function (socket) {
      var my_user = userList.id;
      socket.on('userData', function (userDetails) {
          userDetails.socket = socket;
          userList[userDetails.id] = userDetails
      });
  
  
      var userModule = require('./costum_modules/UserModule.js')(socket);
      userModule.helloWorld();
      var chatModule = require('./costum_modules/ChatModule.js')(socket, userModule);
      var cacheModule = require('./costum_modules/CacheModule.js')(socket, userModule);
      var notificationModule = require('./costum_modules/NotificationModule')(socket, sequelize, userList);
  
  });
  </code></pre>
  
  <p>The <code>socket.on</code> methods are working fine in my <code>UserModule</code> however i am unable to call the function <code>helloWorld</code>. if i try i get the following error:</p>
  
  <pre><code>userModule.helloWorld is not a function
  </code></pre>
  
  <p>So my question is, is what i am trying to do even possible? how am i able to store <code>objects</code>, <code>functions</code> ect in a module for later use?</p>