Search code examples
javascriptcssangulartwitter-bootstrapangular6

Can´t add Bootstrap 4 in Angular 6


I have the problem when I try to add the latest bootstrap version with

npm install bootstrap

After that, I got an error message when I tried to run it.

ng serve --open

I Add Bootstrap in angular.json

like this

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

And the error message is

    ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css
Module not found: Error: Can't resolve '...\node_modules\bootstrap\dist\css\bootstrap.min.css' in '...'

Why did I get the error message?


Solution

  • Delete "../node_modules/bootstrap/dist/css/bootstrap.min.css", in the Angular.json.

    Try add this @import "~bootstrap/dist/css/bootstrap.css"; to your style.css file.

    Ref: Styling Angular CLI v6 apps with Bootstrap