简体   繁体   English

Angular 2没有为CompilerFactory提供程序

[英]Angular 2 No provider for CompilerFactory

I'm getting this error on my Ahead-of-Time compiled application: 我在提前编译的应用程序上收到此错误:

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

Application is built using NGC to generate the .ngfactory files, then TSC with a different main file to get the JS, then rollup w/Babel to complete the build. 使用NGC生成应用程序,以生成.ngfactory文件,然后使用具有不同main文件的TSC来获取JS,然后使用w / Babel汇总来完成构建。 Following this guide fairly closely. 非常仔细地遵循指南。

Here's my main.prod.ts : 这是我的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)
platformBrowser().bootstrapModule(<any> AppModuleNgFactory)

应该

platformBrowser().bootstrapModuleFactory(AppModuleNgFactory)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM