title: Backbone Marionette: Marionette.Application causing Require.js module load error, "'Error: Module name 'App' has not been loaded yet for context: _"
body: <p>I'm trying to include the App instance to use it's event aggregator as shown <a href="https://github.com/derickbailey/backbone.marionette/blob/master/docs/marionette.application.md" rel="nofollow">here</a> </p>
  
  <p>I get an error when I include the instance in a view.</p>
  
  <p>Kicking things off in the Requirejs config file, from App.Bootloader.js:</p>
  
  <pre><code>require(['App'], function (App){
        App.start();
        });
  </code></pre>
  
  <p>from App.js:</p>
  
  <pre><code>define(function (require){
  
    //...requisite includes $, _, Backbone, Marionette ...
  
  var Layout = require('Layout');
  
    var App = new Marionette.Application();
  
          App.addRegions({
              main: '#view_content'
          });
  
          App.addInitializer(function (){
  
                  App.main.show(new Layout());
                  //... adding router etc ...    
  
                  Backbone.Marionette.TemplateCache.loadTemplate = function (template, callback){
                     callback.call(this, Handlebars.compile(template));
                  };
                  Backbone.history.start();
  
          });
  
      return App;
  });
  </code></pre>
  
  <p>From Layout.js:</p>
  
  <pre><code>define(function(require){
     var View = require('folder/folder/View');
     //template contains #sub div
     var template = require('text!template.html');
  
     return Marionette.Layout.extend({
        template: template,
        regions: {
           sub: '#sub'
        },
        initialize: function(){
           //wait till template is rendered in dom
           _.defer(function(region){
               region.sub.show(new View());
            }, this)
        }
  
     });
  
  });
  </code></pre>
  
  <p>From /folder/folder/View.js:</p>
  
  <pre><code>define(function (require){
  
        //...requisite includes $, _, Backbone, Marionette ...
  
       var App = require('App');
       return Marionette.ItemView.extend({});
  });
  </code></pre>
  
  <p>Where I get the error "'Error: Module name 'App' has not been loaded yet for context: _"</p>
  
  <p>Any ideas? Lemme know if you need more information.</p>