4
votes

I'm trying to add angular-translate to my angular app. I followed this simple quick start: https://angular-translate.github.io/docs/#/guide, but my app won't bootstrap, giving me the following error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr] Failed to instantiate module pascalprecht.translate due to: Error: [$injector:nomod] Module 'pascalprecht.translate' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

My index.html file is properly including angular-translate like so:

<script src="bower_components/angular-translate/angular-translate.js"></script>

Any clue why this could be happening?. I'd really appreciate the help.

UPDATE

Here's part of my app.js to clarify things a bit:

var app = angular.module('myApp', [
  'ngAnimate',
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngTouch',

  // 3rd party modules.
  'ui.router',
  'restangular',
  'angular.filter',
  'ui.bootstrap',
  'pascalprecht.translate',


  // Custom modules.
  'myApp.config'
])
.
.
.
3
As it says, If registering a module ensure that you specify the dependencies as the second argument. -- so, did you? I.e. could you show a bit more of your code, if you did specify dependencies correctly. - jmustonen
yep I did specify the 'pascalprecht.translate' dependency. I'm updating the question to show a bit of my app.js - Luis Crespo
Ok, things do look to be ok.. did you already check with your browser's network monitor, that the angular-translate.js file is indeed loading correctly? - jmustonen
Yes. The browser is indeed loading the file correctly. angular-translate.js is in the loaded resources. - Luis Crespo
Ok, seems quite weird. Was everything working until you introduced angular-translate? What if you now remove angular-translate dependency and the angular-translate.js from loading? - jmustonen

3 Answers

2
votes

I had faced same problem, resolved it by adding below entries. Also remeber to put these .js files in correct order too.

files : [
         '../js/libs/angular.js',    
          '../libs/angular-route.js', 
          '../angular-translate.min.js',
          '../libs/angular-translate-loader-url.js',

Hope, this helps.

Regards, Aditi.

1
votes

I had other modules depending on the translation module, so I was able to fix this error by loading it right after loading angular itself.

0
votes

It was failing because of another dependency throwing an error, specifically jquery.easy-pie-chart. I wasn't using that dependency at all so I removed it and angular-translate started working without a problem.