[Fixed] I get error ".form-floating>~label" in ng build – Build

by
Ali Hasan
angular angular2formbuilder bootstrap-5 compiler-errors

Quick Fix: In your angular.json file, replace "optimization": true with:

"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
},
"fonts": true
}

If it’s a dev build, you may replace it with "optimization": false altogether.

The Problem:

"form-floating>~label" error in ng build

The Solutions:

Solution 1: Optimization workaround

In your angular.json file, find the "optimization" property and change it to the following:

"optimization": {
  "scripts": true,
  "styles": {
    "minify": true,
    "inlineCritical": false
  },
  "fonts": true
}

This workaround addresses a bug in Angular that causes errors when "optimization" is set to true. By disabling "inlineCritical" for styles, you can resolve the issue.

Solution 2: “Don't” do this (adding bootstrap css to angular.json styles)

Instead of adding the Bootstrap CSS to the angular.json styles array, you should import it directly into your CSS file.

Incorrect:

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css"
]

Correct:

In your styles.scss file:

@import '~bootstrap/dist/css/bootstrap.min.css';
@import '~bootstrap-icons/font/bootstrap-icons.min.css';

Q&A

How to fix .form-floating error in angular?

Do not add bootstrap css to angular.json styles,import it in css instead.

Video Explanation:

The following video, titled "How To Fix Adobe Premiere Render and Export Errors (2023 ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

... get awesome stuff: https://linktr.ee/LHTES 0:00 - Intro 0:56 - Good ... How To Fix Error Compiling Movie - Renderer Returned Error In Premiere Pro.