23

I am trying to include bootstrap 3.7 in my angular 2 project by using CLI command -

npm install bootstrap --save

I have requirement to use bootstrap 3.7 version. But, it is installing the latest version of bootstrap i..e bootstrap 4.

How to install specific version of bootstrap using CLI?

Guruling Kumbhar
  • 1,039
  • 1
  • 8
  • 18
  • 1
    Possible duplicate of [How do I install a previous version of an npm package?](https://stackoverflow.com/questions/15890958/how-do-i-install-a-previous-version-of-an-npm-package) – Jota.Toledo Jan 24 '18 at 18:19

8 Answers8

61

From the official bootstrap documentation :

You can also install Bootstrap using npm:

npm install bootstrap@3 --save

Rafik Tighilt
  • 2,071
  • 1
  • 15
  • 27
13

This is related to NPM, not angular. There are 2 ways:

  1. npm install bootstrap@version --save(replace version with the desired version). Using --save is a best pratice. It adds the bootstrap dependencies to package.json
  2. Check your package.json and update "bootstrap": "4.0.0" to 3.3.7
Dexter
  • 4,036
  • 3
  • 47
  • 55
TheUnreal
  • 23,434
  • 46
  • 157
  • 277
7

You Can install Bootstrap Version 3.3.7 using below comment.

$ npm install bootstrap@3.3.7 --save

3

Specify the version you want in the 'dependencies' section of your package.json, then from your root project folder in the console run this:

npm install

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • I have noticed that everyone uses 'npm install bootstrap'. why not 'npm install --save bootstrap'? Will it not throw an error when the codebase is shared with some other developer as it will not be added in package.json but is being referencecd in angular.json file. PS. I am new to angular 7. Just curious to know why people dont use --save for this package – prawwe316 Mar 06 '19 at 18:52
3

Use following command:

npm install bootstrap@version --save

Replace the version with the respective version you need. See the example below to install v.3.3.7

npm install bootstrap@3.3.7 --save
Basil
  • 1,664
  • 13
  • 25
2

You can install bootstrap using npm command.

npm install bootstrap@version --save

Here "@version" is the version of bootstrap. You can replace it by specific version as below.

npm install bootstrap@3.7 --save

You can also use @latest to install latest version of it.

Mohit Bhavsar
  • 371
  • 1
  • 5
2

Install Bootstrap Specific Version in Angular

npm install bootstrap@4.6 --save // 4.6 is a version value you can change it accordingly.

If you like to install bootstrap along with JQuery in Angular

npm install bootstrap@@4.6 jquery --save

Note: you can try without --save also.

Billu
  • 2,733
  • 26
  • 47
0

If you want to install the Bootstarp without jQuery library (which is recommended), there is a package named ng-bootstrap. You can install it by running this script:

npm install ng-bootstrap@latest

Also, it is recommended to install packages using Angular CLI.

You may ask why? Because it can update your project with configuration changes, for example if it needs to update your angular.json, to place css or script file addresses. For more info regarding this, visit Difference between ng add vs npm install QA!

To install using Angular CLI, run this script:

ng add @ng-bootstrap/ng-bootstrap@latest

You can replace @latest version with a target version like @12.0.1, to install an older version, you can find the version history in their github link here

Hassan Monjezi
  • 1,060
  • 1
  • 8
  • 24