Open ghost opened 6 years ago
Same issue for me as well - NullInjectorError: No provider for class{}! serve and build work fine. build prod causes the error.
My local environment:
Angular CLI: 1.7.3
Node: 8.9.1
OS: darwin x64
Angular: 5.2.8
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
angular/cdk: 5.2.4
angular/cli: 1.7.3
angular-devkit/build-optimizer: 0.3.2
angular-devkit/core: 0.3.2
angular-devkit/schematics: 0.3.2
ngtools/json-schema: 1.2.0
ngtools/webpack: 1.10.2
schematics/angular: 0.3.2
schematics/package-update: 0.3.2
typescript: 2.6.2
webpack: 3.11.0
Same issue for me as well - StaticInjectorError[i]. With webpack 4 and Angular 6 to compile AOT (@ngtools_webpack)
I had this problem and it drove me nuts... i finally figured it out... by turning off build-optimizer ( for Es2015 targets - known bug) and source-maps on for --prod in angular.json which gave a error pointing me to, providing Options-Object for angular2-logger, in app.module.ts like:
import { Logger as FgLogService, Level, Options } from 'angular2-logger/core';
and import it in the provider-section:
...
providers: [
...
// Provide Options-object for angular2-logger aka FgLogService
{ provide: Options, useValue: { store: false } },
...
]
...
Hope this helps someone... i guess the problem is that uglify removes default options-object? But couldn't verify... would explain why it only breaks on build...
@FloNeu Thank you so much, searched for hours! This solved my issue.
Uncaught Error: StaticInjectorError[i]: StaticInjectorError[i]: NullInjectorError: No provider for
i!``The app work correctly when 'serve' or 'build' but got error 'StaticInjectorError' when build prod optimizer.