How can I install two versions of Bootstrap with NPM into a single node_modules folder?

868 views Asked by At

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.

1

There are 1 answers

0
Giovan Cruz On

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

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