title: Accessing Models in Node.js using Express
body: <p>I'm new to node.js and am not entirely sure how to access models in my <code>app.js</code> file.  My file structure is as follows: </p>
  
  <pre><code>- controllers 
  - helpers 
  - middlewares
  - models 
  - node_modules 
  - public 
  - tests 
  - views 
  app.js 
  package.json 
  </code></pre>
  
  <h1>App.js</h1>
  
  <p>Within my <code>app.js</code> I have: </p>
  
  <pre><code>var express = require('express'); 
  var app = express(); 
  
  app.set('view engine', 'jade');
  app.use(express.static(__dirname + '/public'));
  
  var models = require('./models'); 
  
  
  app.get('/', function(req, res){
      res.render('index', {title: 'Mosaic Viewer'}); 
  }); 
  
  app.get('/map', function(req, res){
      var blockMosaicStreamer = models.BlockMosaicStreamer(); 
      res.render('view', {type: "block", name: "Sara", latitude: "", longitude: "", zoom: ""}); 
  }); 
  
  app.listen(3000, function(){
      console.log('Mosaic Tile Server listening on port 3000...'); 
  }); 
  </code></pre>
  
  <p>When I try <code>var models = require('./models')</code> I get: </p>
  
  <blockquote>
    <p>Error: Cannot find module './models'</p>
  </blockquote>
  
  <p>I'm really new to this so I think it may just be a conceptual misunderstanding.  Can anyone help me out? </p>