在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)
答案 0 :(得分:-1)
如果您使用CookieService,请确保执行以下步骤
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]
})