3

I am working on a project where I am using angular 10 and trying to use Bootstrap library, but the issue is BootStrap styles are not loading.

In package.json I can see bootstrap dependency there.

"bootstrap": "^3.4.1",

I tried to debug in every possible way but not able to figure out yet as I am new to Bootstrap.

Don't want to see my button like this.

Currently, the button is looking like this

Any help would be highly appreciated.

7 Answers 7

10

When using bootstrap in angular there are several ways of adding it in. The most effective approach for me is to run ng add @ng-bootstrap/ng-bootstrap in the root of your project which will add required data in your angular.json and your package.json.

I should note that you have to have Angular Cli version greater than 9.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes CLI version is 10.0.3.
Glad to hear it. Could you mark this answer as the answer so other people with the same problem know where to look?
3

if u add bootstrap while sever is already running it won't affect.. we should restart the server then it will work .. if not check the below steps

make sure u have this code in ur angular.json file

"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]

to install bootstrap and jquery use this cmds ..first go to ur app diectory then open terminal hit this cmds

npm install bootstrap@latest --save

npm install jquery@latest --save

1 Comment

This works for me! I Returning from another branch that doesn't use bootstrap, and without restarting the server, made it not load automatically. All what i had to do is to do a restart of the server. That's it.
1

I had the same issue and after restarting the server it just works fine for me. I installed it from the npm using the npm install command.

1 Comment

If you installed using npm install command during the server already running, this is the best approach.
1

I was expecting to see the bootstrap.css in the html <head> section like everyone was saying for older versions, but instead it was hidden, bundled in the styles.css file in the browser.

Only these steps were required:

npm install --save bootstrap

And in angular.json, unde build (not test):

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

Now run ng serve again

Comments

0

Include Bootstrap link <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> in index.html file and recompile the apps it will work or second way is to include your bootstrap assets path in angular.json -> projects -> architect -> styles

2 Comments

Tried doing it, still not working. Any other walk around?
it's only add the style in the part of styles in the angular.json. If you only work with ng-bootstrap (for me the best option), download bootstrap.min.css, copy in a folder of your application and indicate in angular.json
0

Another walk around to this, If bootstrap is successfully installed and still Bootstrap styles not loading , just add

node_modules/bootstrap/dist/css/bootstrap.min.css"

in your angular.json.

Styles will be visible now.

Comments

0

Go to the package.json and check if the versions are right.sometimes you got a bad combination when are installing popper,jquery and bootstrap. for example

//package.json
"dependencies": {
"bootstrap": "^4.6.0",
"jquery": "^3.5.1",
"popper.js": "^1.16.1"
}

and in the //angular.json

"styles": [
              "src/styles.css",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css"
            ],
            "scripts": [
              "./node_modules/jquery/dist/jquery.min.js",
          "./node_modules/popper.js/dist/umd/popper.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js"
            ]

remember delete node_modules and package-lock.json if you are modifying the file package. and at the end re install all again with npm install

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.