title: cordova.js causes reference error 'require is not defined'
body: <p>I'm wish to use <strong>ngCordova</strong> to detect the network state of a device.  However, as soon as I include <strong>cordova.js</strong> I get an error -</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: require is not defined (cordova.js:23)</p>
  </blockquote>
  
  <p>I've installed and am successfully running <strong>Node.js</strong> and <strong>Cordova</strong>, and I've downloaded and installed <strong>ngCordova</strong> <a href="http://ngcordova.com/docs/install/" rel="nofollow">following the instructions here</a>.</p>
  
  <p>I have also installed the <strong>network-information</strong> plugin via the <strong>Cordova CLI</strong> -</p>
  
  <blockquote>
    <p>cordova plugin add cordova-plugin-network-information</p>
  </blockquote>
  
  <p>As per the documentation this is the code sample that I'm using (and to clarify, the error occurs as soon as I include cordova.js, so even without this code snippit I still get the error;  this is show my end goal) -</p>
  
  <pre><code>var app = angular.module('myApp', ['ngCordova']);
  
  app.controller('myCtrl', ['$rootScope', '$scope', '$cordovaNetwork', function($rootScope, $scope, $cordovaNetwork){
  
      document.addEventListener("deviceready", function () {
  
          var type = $cordovaNetwork.getNetwork()
  
          var isOnline = $cordovaNetwork.isOnline()
  
          var isOffline = $cordovaNetwork.isOffline()
  
  
          // listen for Online event
          $rootScope.$on('$cordovaNetwork:online', function(event, networkState){
              var onlineState = networkState;
          })
  
          // listen for Offline event
          $rootScope.$on('$cordovaNetwork:offline', function(event, networkState){
              var offlineState = networkState;
          })
  
      }, false);
  
  }]);
  </code></pre>
  
  <p>In my <strong>index.html</strong> file I've made sure that I have declared the files are required in the order specified -</p>
  
  <ol>
  <li><code>angular.min.js</code></li>
  <li><code>ngCordova.min.js</code></li>
  <li><code>cordova.js</code></li>
  </ol>
  
  <p>How can I fix this error?</p>