Step 1: Install Bootstrap and jQuery
-
Install Bootstrap
To install the latest version of Bootstrap, run:npm install bootstrap
If you want to install a specific version of Bootstrap, like version 3.3.7, use:
npm install bootstrap@3.3.7
-
Install jQuery
To install jQuery, run:npm install jquery
Step 2: Check if Bootstrap and jQuery are Installed
After running the above commands, you can check if Bootstrap and jQuery are listed in your package.json
file under dependencies
:
"dependencies": {
"bootstrap": "^5.0.0", // or the version you installed
"jquery": "^3.6.0" // or the version you installed
}
Step 3: Register Bootstrap and jQuery in angular.json
To use Bootstrap and jQuery in your Angular project, you need to register them in the angular.json
file under the styles
and scripts
arrays.
-
Add Bootstrap CSS to
angular.json
In theangular.json
file, add the Bootstrap CSS file to thestyles
array:"styles": [ "src/styles.css", "node_modules/bootstrap/dist/css/bootstrap.min.css" ]
-
Add jQuery and Bootstrap JS to
angular.json
In thescripts
array, add jQuery and Bootstrap JS (if you’re using Bootstrap JavaScript components):"scripts": [ "node_modules/jquery/dist/jquery.min.js", "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" ]
This ensures that Bootstrap and jQuery are included in your project, and you can use their styles and functionality.
Final angular.json
Example
Here’s an example of how the relevant parts of your angular.json
might look after adding Bootstrap and jQuery:
"projects": {
"your-project-name": {
"architect": {
"build": {
"options": {
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]
}
}
}
}
}
Key Points:
npm install bootstrap
installs the Bootstrap CSS and JavaScript files.npm install jquery
installs the jQuery library.- You need to add both Bootstrap CSS and JavaScript (along with jQuery) to the
angular.json
file to use them globally in your Angular application.