Search code examples
angularangular5ng-bootstrapangular-bootstrap

Cannot install bootstrap in angular 5


Initially I installed bootstrap using below command:

npm install --save bootstrap

It was installed successfully and I am trying to add CSS like below:

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

In angular cli file. But when i run the project i got the error like below.

@ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-
 loader/lib?{"ident":"postcss","sourceMap":false}!./src/styles.css 3:10-192 
@ ./src/styles.css 
@ multi ./node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css

Solution

  • It is because, there is an issue with bootstrap 4.0.0. Downgrade bootstrap version to 4.0.0-beta.2 in package.json.

    "bootstrap": "4.0.0-beta.2"
    

    For more information check this issue

    or you can upgrade angular-cli version as it is suggested in the thread. Mine is 1.6.3