Skip to content
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

@angular-devkit/build-angular 0.802.0-next.1 throws ERROR NullInjectorError: StaticInjectorError #15145

Closed
1 task done
naveedahmed1 opened this issue Jul 22, 2019 · 7 comments · Fixed by #15165
Closed
1 task done

Comments

@naveedahmed1
Copy link

naveedahmed1 commented Jul 22, 2019

🐞 Bug report

Command

  • build

Is this a regression?

It was working fine in "@angular-devkit/build-angular": "0.802.0-next.0", and is broken in "@angular-devkit/build-angular": "0.802.0-next.1",.

Yes, the previous version in which this bug was not present was:

"@angular-devkit/build-angular": "0.802.0-next.0"

Description

After upgrading my application from "@angular-devkit/build-angular": "0.802.0-next.0", to "@angular-devkit/build-angular": "0.802.0-next.1",. The application is throwing below error:

ERROR NullInjectorError: StaticInjectorError(a)[D -> Q]: 
  StaticInjectorError(Platform: core)[D -> Q]: 
    NullInjectorError: No provider for Q!
    at oe.get 

With sourcemaps enabled, it points to below code:

() => navigator.serviceWorker.register(script, { scope: options.scope })
            .catch((/**
         * @param {?} err
         * @return {?}
         */
        err => console.error('Service worker registration failed with:', err)))));

🔥 Exception or Error


ERROR NullInjectorError: StaticInjectorError(a)[D -> Q]: 
  StaticInjectorError(Platform: core)[D -> Q]: 
    NullInjectorError: No provider for Q!
    at oe.get 

🌍 Your Environment


Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.802.0-next.1
@angular-devkit/build-angular              0.802.0-next.1
@angular-devkit/build-optimizer            0.802.0-next.1
@angular-devkit/build-webpack              0.802.0-next.1
@angular-devkit/core                       8.2.0-next.1
@angular-devkit/schematics                 8.2.0-next.1
@angular/cdk                               8.1.1
@angular/cli                               8.2.0-next.1
@angular/fire                              5.2.1
@angular/flex-layout                       8.0.0-beta.26
@angular/http                              8.0.0-beta.9
@angular/material                          8.1.1
@angular/material-moment-adapter           8.1.1
@angular/pwa                               0.802.0-next.1
@ngtools/webpack                           8.2.0-next.1
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        8.2.0-next.1
@schematics/update                         0.802.0-next.1
rxjs                                       6.5.2
typescript                                 3.4.5
webpack                                    4.35.3
@alan-agius4
Copy link
Collaborator

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

It’s also worth mentioning in the above list of packages @angular-devkit/build-angular is not next-1 but next-0.

@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Jul 22, 2019
@naveedahmed1
Copy link
Author

@alan-agius4 thank you for quick reply. I will share the repo soon. I have updated the issue and have updated the ng version output from the affected project.

@adrogon
Copy link

adrogon commented Jul 24, 2019

It might not be the exact same issue, but I end up with a similar stacktrace with this simple reproduction using flex-layout. Please notice it only fails when buildOptimizer is enabled.

Reproduction repo

https://github.com/adrogon/repro-build-optimizer

4 branches: 3 successes, 1 failure

✔️ git checkout works-in-next0-and-aot-only && npm i && ng serve
initialises the project and shows it works nominally in 0.802.0-next.0 and aot enabled.

✔️ git checkout still-works-in-next0-and-build-optimizer && npm i && ng serve
shows it still works when enabling buildOptimizer and not upgrading to 0.802-next.1.

✔️ git checkout still-works-in-next1-and-aot-only && npm i && ng serve
shows it works in 0.802-next.1 when buildOptimizer is not enabled.

git checkout fails-in-next1-and-build-optimizer && npm i && ng serve
is the merge of the 2 previous branches, shows it fails in 0.802-next.1 with buildOptimizer enabled.

Stacktrace

ERROR NullInjectorError: StaticInjectorError(AppModule)[DefaultLayoutAlignDirective -> StyleUtils]: 
  StaticInjectorError(Platform: core)[DefaultLayoutAlignDirective -> StyleUtils]: 
    NullInjectorError: No provider for StyleUtils!
    at NullInjector.get (http://localhost:4200/vendor.js:7869:27)
    at resolveToken (http://localhost:4200/vendor.js:9632:24)
    at tryResolveToken (http://localhost:4200/vendor.js:9558:16)
    at StaticInjector.get (http://localhost:4200/vendor.js:9421:20)
    at resolveToken (http://localhost:4200/vendor.js:9632:24)
    at tryResolveToken (http://localhost:4200/vendor.js:9558:16)
    at StaticInjector.get (http://localhost:4200/vendor.js:9421:20)
    at resolveNgModuleDep (http://localhost:4200/vendor.js:33973:29)
    at NgModuleRef_.get (http://localhost:4200/vendor.js:35059:16)
    at resolveDep (http://localhost:4200/vendor.js:35586:45)

Environment

Angular CLI: 8.2.0-next.1
Node: 12.4.0
OS: linux x64
Angular: 8.2.0-next.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.802.0-next.1
@angular-devkit/build-angular     0.802.0-next.1
@angular-devkit/build-optimizer   0.802.0-next.1
@angular-devkit/build-webpack     0.802.0-next.1
@angular-devkit/core              8.2.0-next.1
@angular-devkit/schematics        8.2.0-next.1
@angular/cdk                      8.1.1
@angular/cli                      8.2.0-next.1
@angular/flex-layout              8.0.0-beta.26
@ngtools/webpack                  8.2.0-next.1
@schematics/angular               8.2.0-next.1
@schematics/update                0.802.0-next.1
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.35.3

Thanks for reading 😏

@adrogon
Copy link

adrogon commented Jul 25, 2019

Hello @alan-agius4, is this repro enough for you, or do you need anything else?

@jeandat
Copy link

jeandat commented Jul 28, 2019

Shouldn't this issue posted to @angular/flex-layout repo instead?
angular/flex-layout#1107

vikerman pushed a commit that referenced this issue Jul 29, 2019
…h are inside of methods.

With this change we stop recursive lookup when the current node is not a BlockLike.

This change should also, improve the BO overall speed as it's reduces a lot of recursive lookups.

Fixes #15145
@annamajorova0278
Copy link

Ofa 76d40e4

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants