title: Uncaught Error: [$injector:unpr] Unknown provider: $cookiesProvider <- $cookies <- YourHttpInterceptor <- $http <- ng1UIRouter
body: <p>I am getting this error, struggling from hours to solve this. I'm new in MEAN stack development. 
  I am trying to implement the session management in my app. But stuck at this point.</p>
  
  <p>Error: </p>
  
  <blockquote>
    <p>Uncaught Error: [$injector:unpr] Unknown provider: $cookiesProvider &lt;- $cookies &lt;- YourHttpInterceptor &lt;- $http &lt;- ng1UIRouter</p>
  </blockquote>
  
  <pre><code>angular.module('MyApp')
  .factory('YourHttpInterceptor', ['$q', '$cookies', '$location',
  function($q, $cookies, $location) {
  
  
     return {        
          'request': function(config) {
  
              console.log("req");
              config.headers = config.headers || {};
                if ($cookies.get('token')) {
                  config.headers.Authorization = 'Bearer ' + $cookies.get('token');
                }
              return config;
          },       
  
          // Optional method
          'requestError': function(rejection) {
              // do something on request error 
              console.log("inside the request error");
              if (canRecover(rejection)) {
                  return responseOrNewPromise
              }
              return $q.reject(rejection);
          },        
  
          // Optional method        
          'response': function(response) {
              // do something on response success
              console.log("inside the response ");
              return response;
          },
  
          // optional method 
          responseError: function(response) {
            if(response.status === 401) {
              $location.path('/login');
              // remove any stale tokens
              $cookies.remove('token');
              return $q.reject(response);
            }
            else {
              return $q.reject(response);
            }
          }
      };
  }]);
  </code></pre>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>after adding the 'ngCookies'
  Errors:</p>
  
  <blockquote>
    <p>Uncaught Error: [$injector:modulerr] Failed to instantiate module
    MyApp due to: Error: [$injector:modulerr] Failed to instantiate
    module ngCookies due to: Error: [$injector:nomod] Module 'ngCookies'
    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.</p>
  </blockquote>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>angular.module('MyApp', [
      'ngMaterial',
      'ngMdIcons',
      'ui.router',
      'ngCookies',
      'e3-core-ui.services', 
      'e3-core-ui.utils'  
  ])
  
  .config(['$stateProvider', '$routeProvider','$httpProvider','$mdThemingProvider', '$mdIconProvider',  function($stateProvider, $routeProvider, $httpProvider, $mdThemingProvider, $mdIconProvider) { 
   $httpProvider.interceptors.push('YourHttpInterceptor');
  ...
  enter code here
  </code></pre>