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?

1

8 Answers 8

64

From the official bootstrap documentation :

You can also install Bootstrap using npm:

npm install bootstrap@3 --save

Sign up to request clarification or add additional context in comments.

1 Comment

For specific version - npm install [email protected] --save
14

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

Comments

8

You Can install Bootstrap Version 3.3.7 using below comment.

$ npm install [email protected] --save

Comments

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

1 Comment

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
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 [email protected] --save

Comments

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 [email protected] --save

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

Comments

2

Install Bootstrap Specific Version in Angular

npm install [email protected] --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.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.