Reputation:
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
Upvotes: 0
Views: 2729
Reputation: 106
Add
@import "~bootstrap/dist/css/bootstrap.css";
to src/styles file.
Upvotes: 9
Reputation: 13515
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
Upvotes: 1
Reputation: 7294
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
Upvotes: 1