1

我正在尝试将 AOT 集成到我的项目 Angular 项目中。它在运行项目时引发错误。

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

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

4

1 回答 1

1

我假设您正在使用示例应用程序。AOT 在最新版本的 angular-tour-of-heres 中被破坏。早期版本对我有用。(日期为 17/11/2016,SHA:b24aac7)请返回该版本。

于 2016-12-31T18:27:32.810 回答