1

I'm issuing the following npm command to install some files needed by Bootstrap:

npm install browser-sync gulp gulp-sass --save-dev

After this runs, there are 492 folders that contain over 55 MB files installed into the node_modules folder before I've even installed Bootstrap.

I'm trying to install two versions of Bootstrap. I already have version 4 installed, but would also like to install Bootstrap 5 alpha 2, but it seems only one version can live in node_modules at a time. So I have to add a new folder with another node_modules folder full of all these files just to run another version of Bootstrap.

Is there any way I can install two versions of Bootstrap into one node_modules folder to avoid all these duplicate files? Thanks.

Monty
  • 304
  • 2
  • 14
  • Why are you trying to install two versions of Bootstrap? (Asking because it seems likely that "install two versions of Bootstrap" is not the only, or perhaps even best, solution to your problem.) – Trott Oct 05 '20 at 04:08
  • @Trott: I need version 4 for a few sites already in development using version 4, but want to also start using version 5 on an experimental site. – Monty Oct 05 '20 at 04:10

1 Answers1

3

I ran into a similar issue, because in my company project I had another websites that needs older version of bootstrap. So, in a research, based on this answer, the v6.9.0, Mar 2019 of NPM supports aliases. So, all you need to do is to install the duplicated package under an alias, like:

npm install legacy-bootstrap@npm:bootstrap@v4.0.0-alpha.6

Then, instead of include/require bootstrap/js/tab.js you will need to require legacy-bootstrap/js/tab.js

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Giovan Cruz
  • 681
  • 9
  • 21