0

I'm building a map application using the Yeoman AngularJS generator. I've installed angular-google-maps using bower. If I use "grunt serve" to test the app, it works fine and the map loads correctly. If I simply issue "grunt" to build the app, it fails and says "Module 'google-maps' is not available! You either mispelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument."

I'm not really sure why it doesn't work with the default task. I ran "grunt bowerInstall" and confirmed index.html does have a correct reference to angular-google-maps. I'm loading the Google Maps API ahead of it as well.

This is my app.js

angular
  .module('webappApp', [
    'ngCookies',
    'ngResource',
    'ngSanitize',
    'ngRoute',
    'google-maps'
  ])
  .config(function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/main.html',
        controller: 'MainCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
  });
Patrick Grimard
  • 7,033
  • 8
  • 51
  • 68

1 Answers1

1

I managed to fix this. The error was occurring during Karma tests because it wasn't finding the Google Maps API, nor the angular-google-maps sources. So I updated karma.conf.js to pull in the Google Maps API and angular-google-maps sources from bower_components.

files: [
  'http://maps.googleapis.com/maps/api/js?sensor=false',
  'app/bower_components/angular/angular.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-resource/angular-resource.js',
  'app/bower_components/angular-cookies/angular-cookies.js',
  'app/bower_components/angular-sanitize/angular-sanitize.js',
  'app/bower_components/angular-route/angular-route.js',
  'app/bower_components/lodash/dist/lodash.compat.js',
  'app/bower_components/angular-google-maps/dist/angular-google-maps.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js',
  'test/mock/**/*.js',
  'test/spec/**/*.js'
],
Patrick Grimard
  • 7,033
  • 8
  • 51
  • 68