title: Maximum call stack size exceeded with Node + Express + Angular + Angular-route
body: <p>I am starting a SPA with the following stack:</p>
  
  <ul>
  <li>Back-end:
  
  <ul>
  <li>NodeJS + Express</li>
  </ul></li>
  <li>Front-end:
  
  <ul>
  <li>Angular + Angular-route.</li>
  <li>Twitter Bootstrap</li>
  <li>Underscore</li>
  </ul></li>
  </ul>
  
  <p>I have follow many tutorial with similar stack, and my files look like:</p>
  
  <p><strong>package.json</strong></p>
  
  <pre><code>{
    "name": "webportal",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "test"
    },
    "author": "pdonaire",
    "license": "ISC",
    "dependencies" : {
      "express"    : "~4.7.2",
      "morgan"     : "~1.2.2",
      "method-override": "~2.1.2",
      "nodemon": "~1.7.3",
      "bootstrap": "~3.3.5",
      "angular": "~1.4.7",
      "angular-route": "~1.4.7",
      "underscore": "~1.8.3",
      "jquery": "~2.1.4"
    }
  } 
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>var express = require('express');
  
  var app = express();
  
  app.use('/node_modules', express.static(__dirname + '/node_modules'));
  app.use('/js', express.static(__dirname + '/public/assets/js'));
  
  var indexRoute = function(req, res) {
      res.sendfile('./public/index.html'); // load the single view file (angular will handle the page changes on the front-end)
  };
  
  app.get('/', indexRoute);
  app.get('*', indexRoute);
  
  
  var server = app.listen(3000, function () {
      var host = server.address().address;
      var port = server.address().port;
  
      console.log('Webportal listening at http://%s:%s', host, port);
  });
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" ng-app="WebPortal"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;script src="/node_modules/angular/angular.js"&gt;&lt;/script&gt;
      &lt;script src="/node_modules/angular-route/angular-route.js"&gt;&lt;/script&gt;
      &lt;title&gt;WebPortal&lt;/title&gt;
      &lt;link href='/node_modules/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet'&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="container-fluid"&gt;
      &lt;div ng-view&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;script src="/js/app.js"&gt;&lt;/script&gt;
  &lt;script src="/js/contact.js"&gt;&lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var app = angular.module('WebPortal', ['ngRoute']);
  
  app.config(['$routeProvider',
      function ($routeProvider) {
          $routeProvider.
              when('/contacts', {
                  templateUrl: 'contact.html',
                  controller: "ContactCtrl"
              }).
              otherwise({
                  redirectTo: "/contacts"
              });
      }
  ]);
  </code></pre>
  
  <p><strong>contact.js</strong></p>
  
  <pre><code>app.controller('ContactCtrl', function ($scope, $http, $location) {
  });
  </code></pre>
  
  <p><strong>contact.html</strong> </p>
  
  <p><code>&lt;h1&gt;CONTACT&lt;/h1&gt;</code></p>
  
  <p>Ok. Now I open a CMD and run <code>node index.js</code>. All works and when I open a Chrome tab with <code>http://localhost:3000</code> I get the following error in Chrome Developer Tools:</p>
  
  <pre><code>RangeError: Maximum call stack size exceeded at invokeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8791:30)
  at nodeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8289:11)
  at compositeLinkFn (http://localhost:3000/node_modules/angular/angular.js:7680:13)
  at compositeLinkFn (http://localhost:3000/node_modules/angular/angular.js:7684:13)
  at publicLinkFn (http://localhost:3000/node_modules/angular/angular.js:7555:30)
  at link (http://localhost:3000/node_modules/angular-route/angular-route.js:985:7)
  at invokeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8789:9)
  at nodeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8289:11)
  at compositeLinkFn (http://localhost:3000/node_modules/angular/angular.js:7680:13)
  at publicLinkFn (http://localhost:3000/node_modules/angular/angular.js:7555:30) &lt;div ng-view="" class="ng-scope"&gt;(anonymous function) @ angular.js:12477(anonymous function) @ angular.js:9246invokeLinkFn @ angular.js:8791nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680publicLinkFn @ angular.js:7555boundTranscludeFn @ angular.js:7699controllersBoundTransclude @ angular.js:8316update @ angular-route.js:935link @ angular-route.js:900invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289compositeLinkFn @ angular.js:7680compositeLinkFn @ angular.js:7684publicLinkFn @ angular.js:7555link @ angular-route.js:985invokeLinkFn @ angular.js:8789nodeLinkFn @ angular.js:8289
  
  angular.js:12477 RangeError: Maximum call stack size exceeded
  at Object.ASTCompiler.compile (http://localhost:3000/node_modules/angular/angular.js:13310:10)
  at Parser.parse (http://localhost:3000/node_modules/angular/angular.js:14146:29)
  at $parse (http://localhost:3000/node_modules/angular/angular.js:14248:39)
  at Scope.$eval (http://localhost:3000/node_modules/angular/angular.js:15989:16)
  at update (http://localhost:3000/node_modules/angular-route/angular-route.js:948:26)
  at link (http://localhost:3000/node_modules/angular-route/angular-route.js:900:9)
  at invokeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8789:9)
  at nodeLinkFn (http://localhost:3000/node_modules/angular/angular.js:8289:11)
  at compositeLinkFn (http://localhost:3000/node_modules/angular/angular.js:7680:13)
  at compositeLinkFn (http://localhost:3000/node_modules/angular/angular.js:7684:13) &lt;!-- ngView:  --&gt;
  </code></pre>
  
  <p>Anyone knows what's happening? I don't see naything strange....</p>
  
  <p>Thanks!!!</p>
  
  <p><em>EDIT 1</em>: Added contact.html code</p>
  
  <p><em>EDIT 2</em>: Added screenshot with Chrome Developer Tools console tab:</p>
  
  <p><a href="https://i.stack.imgur.com/57nSs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/57nSs.png" alt="Screenshot 1"></a></p>
  
  <p>*EDIT 3: Added screenshot with Chrome Developer Tools Network tab:</p>
  
  <p><a href="https://i.stack.imgur.com/eU5y7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eU5y7.png" alt="Screenshot 2"></a></p>