0

I have installed bootstrap version 3.4 using Angular cli. Below is the command I used npm install --save bootstrap@3 Then I have added

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

In angular.json file. But I am unable to access the bootstrap default style class. No bootstrap file is showing in browser console whenever I run the application.

I am unable to find the issue here. Your help would be greatly appreciated. Adding screenshot of my node_modules folder node_modules

  • Does this answer your question? [How to add bootstrap in angular 6 project?](https://stackoverflow.com/questions/50290197/how-to-add-bootstrap-in-angular-6-project) – Vikas Feb 18 '20 at 06:37

3 Answers3

9

Add

@import "~bootstrap/dist/css/bootstrap.css";

to src/styles file.

Azametzin
  • 5,223
  • 12
  • 28
  • 46
1

Your paths shouldn't start with a ./.

Instead, try the following:

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

This now makes them relative to the project root.

Working demo: https://stackblitz.com/edit/angular-etn2fd

Kurt Hamilton
  • 12,490
  • 1
  • 24
  • 40
1

Remove relative path use like below. As src is used directly just like that use node_modules not ./node_modules

"styles": [

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

A good resource link is

https://medium.com/@oyewusioyekunle/how-to-add-bootstrap-to-your-angular-project-angular-8-6379fd6a0f46

Passionate Coder
  • 7,154
  • 2
  • 19
  • 44