title: Angularjs: [$injector:modulerr] Failed to instantiate module ui-router
body: <p>I'm a relative newbie in Angular and after following the tutorial I now want to build something from scratch on my own. So I'm trying to set up a basic app in which I want to use <a href="https://github.com/angular-ui/ui-router/wiki" rel="nofollow">the $stateProvider</a> (since I read that it is better than the $routeProvider). So this is my html:</p>
  
  <pre><code>&lt;html ng-app="formApp"&gt;
  &lt;head&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"&gt;&lt;/script&gt;
      &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
      &lt;script src="js/app.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div ng-view&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and my <code>app.js</code> looks like this:</p>
  
  <pre><code>'use strict';
  
  var formApp = angular.module('formApp', ['ui-router']);
  
  formApp.config(function($stateProvider, $urlRouterProvider){
      $stateProvider
          .state('main', {
              url: '/main',
              templateUrl: 'templates/main.html',
              controller: 'MainCtrl'
          });
  
      $urlRouterProvider.otherwise('/main')
  });
  </code></pre>
  
  <p>But I get a massive error in the console, saying:</p>
  
  <pre><code>Error: [$injector:modulerr] Failed to instantiate module formApp due to:
  [$injector:modulerr] Failed to instantiate module ui-router due to:
  [$injector:nomod] Module 'ui-router' 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.
  http://errors.angularjs.org/1.4.3/$injector/nomod?p0=ui-router
  minErr/&lt;@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:68:12
  etc. etc.
  </code></pre>
  
  <p>I understand that <code>'ui-router'</code> in my app declaration is obviously wrong, but without it I get the even bigger error below. </p>
  
  <p>Any idea how I can solve this? All tips are welcome!</p>
  
  <pre><code>Error: [$injector:modulerr] Failed to instantiate module formApp due to:
  [$injector:unpr] Unknown provider: $stateProvider
  http://errors.angularjs.org/1.4.3/$injector/unpr?p0=%24stateProvider
  minErr/&lt;@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:68:12
  createInjector/providerCache.$injector&lt;@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4262:19
  getService@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4409:39
  invoke@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4441:1
  runInvokeQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4356:11
  loadModules/&lt;@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4365:11
  forEach@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:336:11
  loadModules@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4346:5
  createInjector@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:4272:11
  bootstrap/doBootstrap@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:1630:20
  bootstrap@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:1651:1
  angularInit@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:1545:5
  @https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:28359:5
  trigger@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:2996:7
  createEventHandler/eventHandler@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js:3271:9
  
  http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=formApp&amp;p1=%5B%24injector%3Aunpr%5D%20Unknown%20provider%3A%20%24stateProvider%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.4.3%2F%24injector%2Funpr%3Fp0%3D%2524stateProvider%0AminErr%2F%3C%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A68%3A12%0AcreateInjector%2FproviderCache.%24injector%3C%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4262%3A19%0AgetService%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4409%3A39%0Ainvoke%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4441%3A1%0ArunInvokeQueue%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4356%3A11%0AloadModules%2F%3C%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4365%3A11%0AforEach%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A336%3A11%0AloadModules%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4346%3A5%0AcreateInjector%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A4272%3A11%0Abootstrap%2FdoBootstrap%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A1630%3A20%0Abootstrap%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A1651%3A1%0AangularInit%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A1545%3A5%0A%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A28359%3A5%0Atrigger%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A2996%3A7%0AcreateEventHandler%2FeventHandler%40https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.4.3%2Fangular.js%3A3271%3A9%0A
  </code></pre>