Ad

Error: StaticInjectorError On Deployed Angular CLI Project

- 1 answer

We have an Error when deploying our Angular CLI (v.1.7.1) project to GitHub Pages, and Firebase - both give the same result.

The ng serve works perfectly fine on localhost:4200 and all is going well when building production ng build --prod --base-href "https://<user-name>.github.io/<repo>/" and ngh command, the files are being loaded, but when we open it, nothing comes up (just the blank index.html) and we get the following error in the console:

main.e17a4a9….bundle.js:1 ERROR Error: StaticInjectorError(Ru)[e -> e]: 
  StaticInjectorError(Platform: core)[e -> e]: 
    NullInjectorError: No provider for e!
    at e.get (main.e17a4a9….bundle.js:1)
    at main.e17a4a9….bundle.js:1
    at e (main.e17a4a9….bundle.js:1)
    at e.get (main.e17a4a9….bundle.js:1)
    at main.e17a4a9….bundle.js:1
    at e (main.e17a4a9….bundle.js:1)
    at e.get (main.e17a4a9….bundle.js:1)
    at Ii (main.e17a4a9….bundle.js:1)
    at main.e17a4a9….bundle.js:1
    at Ni (main.e17a4a9….bundle.js:1)

Ad

Answer

Build your app with the optimization-feature disabled:

ng build --prod --optimization=false

This way, you'll see an error pointing to the real problem, instead of just "e".

Ad
source: stackoverflow.com
Ad