Reputation: 279
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.
Upvotes: 4
Views: 2928
Reputation: 31
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....
Upvotes: 3
Reputation: 1120
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!!
Upvotes: 9
Reputation: 140
For Jquery , yes you can, see the Node part here , you'll find instructions: https://www.npmjs.com/package/jquery
Or you can just declare the script file.
But for bootstrap , i believe that you should include the css and js files downloaded from npm (you'll find them in the node_modules directory) directly into the webpage , because bootstrap isn't really a package , it's a css framework.
Upvotes: 0