AOT:抛出“找不到模块'../aot/app/app.module.ngfactory'”

时间:2016-12-23 07:18:56

标签: aot angular2-aot

我正在尝试将AOT集成到我的项目角度项目中。它在运行项目时抛出错误。

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 

我使用了systemjs.config文件,如下所示

    (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);  

我不知道为什么会出现这种类型的错误,请提出解决方案。

1 个答案:

答案 0 :(得分:1)

我假设您正在使用示例应用。 AOT在最新版本的角度巡回英雄中被打破。 早期版本适合我。 (2016年11月17日,SHA:b24aac7) 请回到那个版本。