title: Runtime error on Angular app when AoT is enabled
body: <p>I recently updated my app's Angular version from 2.4 to 5.1.2, following the guidelines in this tool: <a href="https://angular-update-guide.firebaseapp.com/" rel="nofollow noreferrer">https://angular-update-guide.firebaseapp.com/</a>. I'm also using angular-cli 1.6.3</p>
  
  <p>Now, after updating, everything works in dev mode when running <code>ng serve</code>. Also <code>ng build</code> (with or without <code>--aot</code> flag) runs without errors. However, <code>ng serve --aot</code> or <code>ng serve --prod</code> produces a runtime error:</p>
  
  <p><a href="https://i.stack.imgur.com/8YeyQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8YeyQ.png" alt="ng serve --aot runtime error"></a></p>
  
  <p>I have found it very difficult to debug this problem, because the stack trace doesn't point to any file written by me. Could it perhaps be a bootstrapping problem?</p>
  
  <p>At this point I'm not looking for complete solutions to the issue, but suggestions as to where I could start looking.</p>
  
  <p>I have tried so far:</p>
  
  <ul>
  <li>Searching for similar issues, this could be related: <a href="https://stackoverflow.com/questions/47884127/error-when-loading-a-angular-app-with-aot-build-on-amazon-s3">Error when loading a Angular app with AOT build on Amazon S3</a></li>
  <li>Checked that my bootstrapping configuration in <code>main.ts</code> matches some examples</li>
  <li>Updated node from 9.1.0 to 9.3.0 (Suggested by Vincent)</li>
  <li>Created a new angular-cli project and copied the polyfills.ts file from the new project to my existing one</li>
  </ul>