Bootstrap styles not loading
Hi,
I followed the steps for Global Library Installation https://github.com/angular/angular-cli#global-library-installation
-
Installed [email protected] npm install bootstrap --save
-
Then added the needed script files to to apps[0].scripts in angular-cli.json file:
"scripts": [
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
and the Bootstrap CSS to the apps[0].styles array:
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.css"
],
- Restarted ng serve
But the bootstrap styles are not loading
OS- Windows 7 Enterprise
angular-cli: 1.0.0-beta.21 node: 6.9.1 os: win32 x64
Okay
On Wed 2 May, 2018, 2:06 AM irfanakbar47, [email protected] wrote:
Restart npm server
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/3411#issuecomment-385782090, or mute the thread https://github.com/notifications/unsubscribe-auth/AYVbk57P9H1m-pwjj_ClfjoMvHXUa6onks5tuMdGgaJpZM4LEpPr .
restart the application using ng serve
@alextait1 Works like a charm. Thank you so much :)
manojsgh solution works for me, I was trying the filipesilva solution but wihout results.
I ran into the same issue,Bootstrap was not loading with Angular 6, no matter how I tried to import , finally solved by downgrading bootstrap 4 to 3
add to styles.css @import "~bootstrap/dist/css/bootstrap.min.css";
I can confirm that this issue is because of bootstrap 4. I am using angular 6 and was trying to include bootstrap v4 it wasn't showing up and then I downgraded to bootstrap v3 and it works like a charm. Simply use the command npm install bootstrap@3 --save to downgrade to bootstrap v3
try removing single dot (.). See below. This worked for me. "./node_modules/bootstrap/dist/css/bootstrap.min.css"
Ran into the same issue and had to downgrade to version 3 of bootstrap and it worked.
I also have the same issue, however I am using version 4.1.3 as I want to be up to date. (The instructor is still using 3.3.7) I am following a Udemy tutorial.
In my angular.json, I have this: "styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.less" ],
because at some point I would like the flexibility of .less.
Downgrading to version 3 isn't a solution and is absurd. Imagine if as a professional developer you got told: "Oh our API won't work with .net core, so you'll have to re-write that app that you've just spent the last 6 months building to perfection in .net 4.5 !" :(
The only way I can get to use the version 4 + styles is to use a CDN link at the top of app\src\styles.css:
@import 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css';
That's great when on occasions the bootstrapcdn server is down and all my users see an unstyled app - very professional.
Could someone PLEASE explain why 4 + can't be used the same as 3.3.7 upwards, WHAT is broke and WHY ?
https://www.techiediaries.com/angular-bootstrap/
That link should clear up a lot of confusion.
Thank You so Much @dotNetAthlete, So cut to the chase, The only thing we need to do is to use the latest Bootstrap: Add @import "~bootstrap/dist/css/bootstrap.css" to your styles.css in the src folder and you are good to go.
P.S : Still need to Install bootstrap first
:-)
I checked all the options and tried each suggested here in the post. But only working option is by uninstalling 4.* version by (npm uninstall bootstrap --save) and next by installing bootstrap 3.3.7 (npm install [email protected] --save)..
**
it worked like charm.
**
for other advanced members/users who dont want to disturb their existing version they have to deal with some intricacies of how to deal with such issues (for e.g. popper.js, jquery.js versions etc) and also know how to map these with the current bootstrap version.. then it might work!
but for me the priority to was to make my learning curve smooth and dont get mingled in these intricacies for now.
all the best!
happy coding.
After installing the bootstrap dependency into your project just plug in the below code in your angular.json file.
"styles": [ "./node_modules/bootstrap/dist/css/bootstrap.min.css" ], "scripts": [ "./node_modules/bootstrap/dist/js/bootstrap.min.js" ]
Using, Angular CLI: 6.2.7 Node: 8.11.1 OS: win32 x64 Angular: 6.1.10
Hope this is helpful!
Had thesame problem. Go to your angular.json And do this: "styles": [ "src/styles.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css" ], 2- Close you server and launch it again: ng-serve.
I had the same issue yesterday. I found a solution to it. I was importing the styles and script files in the wrong place in angular.json file It must be under build and not test object
I found the solution here https://stackoverflow.com/questions/51998505/styles-not-picking-from-angular-json-styles-array-angular-6-but-working-fine-wi
don't work until downgrade , best solution Uninstall angular -> install react -> enjoy
Just put
"scripts": [ "./node_modules/bootstrap/dist/js/bootstrap.js" ],
"styles": [ "styles.css", "./node_modules/bootstrap/dist/css/bootstrap.css" ],
Hope that it would work :)