AOT:throws "Cannot find module '../aot/app/app.module.ngfactory'"

922 views Asked by At

I'm trying to integrate AOT in my project angular project. it throws the error when running the project.

GET http://localhost:3000/aot/app/app.module.ngfactory 404 (Not Found)
scheduleTask @ zone.js:1645
ZoneDelegate.scheduleTask @ zone.js:255
Zone.scheduleMacroTask @ zone.js:168
(anonymous) @ zone.js:1669
send @ VM173:3
fetchTextFromURL @ system.src.js:1051
(anonymous) @ system.src.js:1778
ZoneAwarePromise @ zone.js:536
(anonymous) @ system.src.js:1777
(anonymous) @ system.src.js:2806
(anonymous) @ system.src.js:3384
(anonymous) @ system.src.js:3707
(anonymous) @ system.src.js:4099
(anonymous) @ system.src.js:4562
(anonymous) @ system.src.js:4831
(anonymous) @ system.src.js:407
Zone.run @ zone.js:113
(anonymous) @ zone.js:520
ZoneDelegate.invokeTask @ zone.js:275
Zone.runTask @ zone.js:151
drainMicroTaskQueue @ zone.js:418
ZoneTask.invoke @ zone.js:349
(index):19 Error: (SystemJS) XHR error (404 Not Found) loading        http://localhost:3000/aot/app/app.module.ngfactory
  Error: XHR error (404 Not Found) loading http://localhost:3000/aot/app/app.module.ngfactory
    at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:889:29) [<root>]
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47) [<root> => <root>]
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:345:33) [<root>]
Error loading http://localhost:3000/aot/app/app.module.ngfactory as "../aot/app/app.module.ngfactory" from http://localhost:3000/app/main.js
    at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:889:29) [<root>]
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:151:47) [<root> => <root>]
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:345:33) [<root>]
Error loading http://localhost:3000/aot/app/app.module.ngfactory as "../aot/app/app.module.ngfactory" from http://localhost:3000/app/main.js 

I have used systemjs.config file as below

    (function (global) {
     System.config({
      paths: {
     'npm:': 'node_modules/'
     },
    map: {
  app: 'app',
  // angular bundles
  '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
  '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

  // other libraries
  'rxjs':                      'npm:rxjs',
  'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
      }
   }
  });
 })(this);  

I have no idea why this type of error is coming, please suggest solution.

1

There are 1 answers

0
abdulla syed On

I assume you are working with the sample app. AOT is broken in the latest version of angular-tour-of-heroes. The earlier version works for me. (dated 17/11/2016, SHA:b24aac7) Please go back to that version.