title: Using requireJS with angular; Cannot read property 'module' of undefined
body: <p>Ok, there is a bunch of questions with similar titles, but none of them helped me solve my problem so here it is. </p>
  
  <p>I am trying to use Angular with RequireJS; I am getting the error message <code>Uncaught TypeError: Cannot read property 'module' of undefined</code> which is referring to the <code>angular</code> object within the <code>angular-routes.js file</code>. This suggests to me that requireJS is trying to load angular-routes before angular has loaded. I was under the impression that this wouldn't happen because I have set 'angular-route' as dependant on 'angular' within the shim. Can anyone spot what I am doing wrong here?</p>
  
  <pre><code>// Setup requireJS
  
  require.config({
  
      baseUrl : "scripts",
  
      packages : [
          { "name":"angular", "location":"../bower_components/angular", "main":"angular"},
          { "name":"angular-route", "location":"../bower_components/angular-route", "main":"angular-route"},
          { "name":"angular-animate", "location":"../bower_components/angular-animate", "main":"angular-animate"},
          { "name":"angular-storage", "location":"../bower_components/angular-storage/dist", "main":"angular-storage"},
          { "name":"jquery", "location":"../bower_components/jquery/dist", "main":"jquery"}
  ],
  
     shim:{
          'angular' : { exports : 'angular', deps : ['jquery'] },
          'angular-route' : { deps : ['angular'] },
          'angular-animate' : { deps : ['angular'] },
          'angular-storage' : { deps : ['angular'] },
      }
  
  });
  
  // Load app files
  function loadApp($, app)
  {
      angular.element(document).ready(function(){
          angular.bootstrap(document, ['mealPlannerApp']);    
      });
  }
  requirejs(['app'], loadApp);
  </code></pre>
  
  <p>My <code>app.js</code> file is as follows</p>
  
  <pre><code>(function() {
  
      // Declare AMD module with dependencies
      define(['angular', 'angular-route', 'routes'],
  
      function(config)
      {
  
          var app = angular.module('mealPlannerApp', ['ngRoute', 'ngAnimate', 'ngAnimate']);
          app.config(config);
      });
  
  }());
  </code></pre>