view raw
anonym anonym - 1 year ago 35
Javascript Question

Bootstrap and Jquery with node js

I would like to know if when I run those 2 commands:

npm install jquery
npm install boostrap

Than I add the two dependecies in my package.json file.
Than in my app.js file I code

var $ = require('jquery');
var bootstrap = require('bootstrap');

In my index.ejs file do I need to put a link to a jquery file or a css file or I can use those libraries directly ?

If not, can someone please give the configuration that I need to use bootstrap with npm.


I would suggest you user bower for this kind of stuff as they are going to be served as static. Bower requires a flat dependency tree, so it's easy to manage dependency conflicts (i.e. multiple jquery file).

To install bower:

npm install -g bower

Install bootstrap using bower:

bower install bootstrap --save

Bootstrap has jquery as it's dependency so it will be installed, you won't need to install it separately.

To see path of installed packages:

bower list --path

Now add those path to your index.ejs file. Currently you will see bootstrap.less path. To add bootstrap.css path you will have to find it manually. I think it's in:


To get a clear idea take a look at this.

Hope it helped you. Thanks!!