FortAwesome / angular-fontawesome

Official Angular component for Font Awesome 5+
https://fontawesome.com
MIT License
1.49k stars 152 forks source link

NullInjectorError: No provider for FaIconLibrary! #214

Closed yaseen-nadaf closed 4 years ago

yaseen-nadaf commented 4 years ago

Describe the problem

Uncaught NullInjectorError: StaticInjectorError(AppModule)[AppModule -> FaIconLibrary]: StaticInjectorError(Platform: core)[AppModule -> FaIconLibrary]: NullInjectorError: No provider for FaIconLibrary!

What did you expect?

To work fine

Reproducible test case

Just serve angular universal project with aot enabled in development mode or serve in production mode. I got this error in the console.

My package.json file: "dependencies": { "@angular/animations": "~8.2.14", "@angular/cdk": "^8.2.3", "@angular/common": "~8.2.14", "@angular/compiler": "~8.2.14", "@angular/core": "~8.2.14", "@angular/flex-layout": "^8.0.0-beta.27", "@angular/forms": "~8.2.14", "@angular/material": "^8.2.3", "@angular/material-moment-adapter": "^8.2.3", "@angular/platform-browser": "~8.2.14", "@angular/platform-browser-dynamic": "~8.2.14", "@angular/platform-server": "~8.2.14", "@angular/router": "~8.2.14", "@fortawesome/angular-fontawesome": "^0.6.0-alpha.0", "@fortawesome/fontawesome-svg-core": "^1.2.25", "@fortawesome/free-brands-svg-icons": "^5.11.2", "@fortawesome/free-solid-svg-icons": "^5.11.2", "@fortawesome/pro-duotone-svg-icons": "^5.11.2", "@fortawesome/pro-light-svg-icons": "^5.11.2", "@nguniversal/express-engine": "^8.1.1", "@nguniversal/module-map-ngfactory-loader": "8.1.1", "express": "^4.15.2", "moment": "^2.24.0", "rxjs": "~6.4.0", "tslib": "^1.10.0", "zone.js": "~0.9.1" }

My angular.json file: "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": false, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "budgets": [ { "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" }, { "type": "anyComponentStyle", "maximumWarning": "6kb", "maximumError": "10kb" } ] }

yaseen-nadaf commented 4 years ago

Solved, I saw error #210, downgraded the version to 0.5.0 and changed code to use the global library which was giving me error in console that global library is deprecated. When I saw release 0.5.0, then I came to know that FaIconLibrary is available in 0.5.0 as well so now changed code to use FaIconLibrary and now it's working fine without any error.