title: Angular 2 Ahead-of-Time Compiler Not Finding ngfactory?
body: <p>UPDATE</p>
  
  <p>I am still wokring on this but now the ngc cli does not give me any errors. However it still does not make my NGFactory files. I have updated eveything to the lastest versions. </p>
  
  <p><b>tsconfig.js</b></p>
  
  <pre><code>{
   "compilerOptions": {
     "target": "es5",
     "module": "es2015",
     "moduleResolution": "node",
     "sourceMap": false,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "lib": ["es2015", "dom"],
     "noImplicitAny": true,
     "suppressImplicitAnyIndexErrors": true
   },
  
   "files": [
     "./typescript/modules/app.module.ts"
     // "./typescript/main.ts" &lt;- see (1)
   ],
  
   "angularCompilerOptions": {
      "genDir": "aot",
      "skipMetadataEmit" : true
   }
  }
  </code></pre>
  
  <p>(1) - revoeing this file, which bootstraps my A2 app, and therefore points to my NgFactory file, means that <code>ngc</code> now runs without any errors.</p>
  
  <p>However it seems to read my app.module file, and make a <code>node_modules</code> file and make lots of factory files for A2 itselfs. But my code, my app.module.ngfactory is not in the 'aot' folder that my tsconfig is pointing to!</p>
  
  <h2>Please help!</h2>
  
  <p>I am very new to Angular 2, and have been playing around with using webpack to build a bundle file for me. However, this file is over 3mb. So I thought I would look into using System JS (I ask a question about that). </p>
  
  <p>But while looking to that, I found out why my bundle files where so big, as I was using the JIT compiler method to build the code. So I have been trying to get my simple little app to work (starter app from the Anagular site) to work using the AOH compiler to build. But I can not get it to work.</p>
  
  <p>This is my ts config code: </p>
  
  <pre><code>tsconfig.json
  {
    "compilerOptions": {
      "target": "es5",
      "module": "es2015",
      "moduleResolution": "node",
      "sourceMap": false,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es2015", "dom"],
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
  
    "files": [
      "./typescript/modules/app.module.ts",
      "./typescript/main.ts"
    ],
  
    "angularCompilerOptions": {
     "genDir": "aot",
     "skipMetadataEmit" : true
    }
  }
  </code></pre>
  
  <p>My Component code I added the <code>moduleId</code> into the <code>@Component</code> and the <code>window.module = 'aot';</code> setting into my html file that loads the app. My Component code:</p>
  
  <pre><code>app.components.ts
  
   import { Component } from '@angular/core';
  
   @Component({
     moduleId: module.id,
     selector: 'my-app',
     template: `&lt;h1&gt;Hello {{name}}&lt;/h1&gt;`
   })
  
   export class AppComponent { name = 'Angular'; } 
  </code></pre>
  
  <p>This is my current app module code, unchanged form the example I have used.</p>
  
  <pre><code>app.module.ts
  
   import { NgModule }      from '@angular/core';
   import { BrowserModule } from '@angular/platform-browser';
   import { AppComponent }  from '../components/app.component';
  
   @NgModule({
     imports:      [ BrowserModule ],
     declarations: [ AppComponent ],
     bootstrap:    [ AppComponent ]
   })
  
   export class AppModule { }
  </code></pre>
  
  <p>Now my main.ts file, this is what seems to be giving me my problems. I have changed the import statment to use the <code>NgFactory</code>, however that does not work at all!</p>
  
  <pre><code>Main.ts
  
   import { platformBrowser }    from '@angular/platform-browser';
   import { AppModuleNgFactory } from '../aot/app/app.module.ngfactory'; (1)
  
   platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
  
   (1) - this file is not generted at all!
  </code></pre>
  
  <p>So when I run <code>node_modules/.bin/ngc</code> (running in a Ubuntu 16.04 VM), I get the following error:</p>
  
  <pre><code> Error at /var/www/typescript/main.ts:10:36: 
   Cannot find module './modules/app.ngfactory'. &lt;-- ????????
  </code></pre>
  
  <p>And yes I have installed <code>@angular/compiler-cli &amp; @angular/platform-server</code></p>
  
  <p>And yes I did found this question, <a href="https://stackoverflow.com/questions/38932193/angular-2-ahead-of-time-compilation-how-to">Angular 2 - Ahead-of-time compilation how to</a> - But when I change my main.ts file to point to another folder, I get the same error.... </p>
  
  <p>So what am I doing wrong? </p>
  
  <p>I am also not sure how this plays into building a bundle file with webpack let, has I could not get this to work, I have not gotten that far, but any help would be most welcome.</p>
  
  <p>Thanks.</p>