Angular 5.2.9生产构建问题

时间:2018-03-19 06:59:48

标签: angular

ng build上正常运行,但在Angular 5.2.9上创建生成版本后,生成版本会抛出此错误:

main.3dc2d6370c3c3aa5fa33.bundle.js:1 ERROR Error: StaticInjectorError(r)[n -> n]: 
  StaticInjectorError(Platform: core)[n -> n]: 
    NullInjectorError: No provider for n!
    at n.get (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at main.3dc2d6370c3c3aa5fa33.bundle.js:1
    at n (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at n.get (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at main.3dc2d6370c3c3aa5fa33.bundle.js:1
    at n (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at n.get (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at Mr (main.3dc2d6370c3c3aa5fa33.bundle.js:1)
    at main.3dc2d6370c3c3aa5fa33.bundle.js:1
    at Dr (main.3dc2d6370c3c3aa5fa33.bundle.js:1)

1 个答案:

答案 0 :(得分:-1)

如果您使用CookieService,请确保执行以下步骤

app.module.ts

import { CookieService ,CookieOptions} from 'angular2-cookie/core';
import { CommonModule } from "@angular/common";
import ....

export function cookieServiceFactory() {
  return new CookieService();
}

@NgModule({
  declarations: [
    AppComponent,
     ...
               ],
  imports: [
    BrowserModule,
    ],
  providers: [
    CookieService,
    { provide: CookieOptions, useValue: {} },
    ...
  ],
  bootstrap: [AppComponent]
})