Angular 2没有CompilerFactory的提供程序

时间:2017-01-03 20:12:59

标签: javascript angular angular-compiler-cli

我在我的Ahead-of-Time编译应用程序中收到此错误:

Error: No provider for CompilerFactory!
    at NoProviderError.BaseError [as constructor] (http://localhost:5050/app.js:2413:26)
    at NoProviderError.AbstractProviderError [as constructor] (http://localhost:5050/app.js:2612:19)
    at new NoProviderError (http://localhost:5050/app.js:2651:19)
    at ReflectiveInjector_._throwOrNull (http://localhost:5050/app.js:4637:22)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:5050/app.js:4671:28)
    at ReflectiveInjector_._getByKey (http://localhost:5050/app.js:4625:28)
    at ReflectiveInjector_.get (http://localhost:5050/app.js:4385:24)
    at PlatformRef_._bootstrapModuleWithZone (http://localhost:5050/app.js:10924:64)
    at PlatformRef_.bootstrapModule (http://localhost:5050/app.js:10910:24)
    at http://localhost:5050/app.js:64873:22

使用NGC生成应用程序以生成.ngfactory文件,然后使用不同的main文件生成TSC以获取JS,然后汇总w / Babel以完成构建。紧跟this之后的指导。

这是我的main.prod.ts

import "reflect-metadata";

import { enableProdMode } from "@angular/core";
import { platformBrowser } from "@angular/platform-browser";
import { AppModuleNgFactory } from "./app.module.ngfactory";

enableProdMode();

platformBrowser().bootstrapModule(<any> AppModuleNgFactory)

1 个答案:

答案 0 :(得分:3)

platformBrowser().bootstrapModule(<any> AppModuleNgFactory)

应该是

platformBrowser().bootstrapModuleFactory(AppModuleNgFactory)