Skip to content

Angular CLI build prod optimizer got error. #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ghost opened this issue Jan 27, 2018 · 4 comments
Open

Angular CLI build prod optimizer got error. #178

ghost opened this issue Jan 27, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 27, 2018

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.

@alex-milburn
Copy link

alex-milburn commented Mar 15, 2018

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

@aog1971
Copy link

aog1971 commented May 31, 2018

Same issue for me as well - StaticInjectorError[i].
With webpack 4 and Angular 6 to compile AOT (@ngtools_webpack)

@FloNeu
Copy link

FloNeu commented Jun 7, 2018

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...

@JBusch
Copy link

JBusch commented Aug 17, 2018

@FloNeu Thank you so much, searched for hours! This solved my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants