Angular Build Can't Find Installed Font-Awesome Node_module
Whenever I build my project using ng build --prod I receive the following error: ERROR in ./src/styles.scss Module build failed: ModuleBuildError: Module build failed: Erro
Solution 1:
I was not sure why the CSS version of the file never worked, but I was able to find the docs on the angular-cli that gave me some hints to how to get it working.
1) Import the SCSS version instead of the CSS version.
@import "~font-awesome/scss/font-awesome.scss";
2) Define the font path as a SCSS variable.
$fa-font-path: "~font-awesome/fonts";
Note that the SCSS var have to be defined before the @import
statement.
Weird thing was that thing error randomly happened. Everything was working fine for one developer, but when pulling the repo to a second computer this issue was introduced.
Solution 2:
that works for me (this line is in my main app.css)
@import "node_modules/font-awesome/scss/font-awesome";
Solution 3:
You need to add that inside your .angular-cli.json
file add styles
under apps
like so:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "MyProject",
"ejected": false
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"manifest.json",
{
"glob": "**/*",
"input": "../node_modules/leaflet/dist/images",
"output": "./assets/",
"allowOutsideOutDir": false
}
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"serviceWorker": true,
"styles": [
"assets/sass/global/loading.css",
"../node_modules/font-awesome/css/font-awesome.min.css", <===================
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"demo": "environments/environment.demo.ts",
"prod": "environments/environment.prod.ts",
"qa": "environments/environment.qa.ts",
"e2e": "environments/environment.e2e.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {
}
}
}
Post a Comment for "Angular Build Can't Find Installed Font-Awesome Node_module"