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:
bower_components/bootstrap/dist/css/bootstrap.css
To get a clear idea take a look at this.
Hope it helped you. Thanks!!
There is also a prebuilt bootstrap bower package called bootstrap-css
. I think it will be better to use to keep things minimal and not install unwanted .less
files.
bower install bootstrap-css
Thanks....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With