1

Suppose that I ran

$ npm install bootstrap --save

and now I have, inside the node_modules folder, a bootstrap folder containing a Bootstrap distribution. What am I supposed to do with it?

Here's the (simplified) structure of my project, a template for writing blog posts (https://github.com/jacquerie/portfolio-template):

.
├── Gruntfile.js
├── css
│   └── application.css
├── index.html
├── js
│   └── application.js
├── package.json
└── node_modules
    └── bootstrap

I could do something like

$ cp node_modules/bootstrap/dist/css/bootstrap.css css

but that looks rather unelegant and it's a manual step I don't want to remember to do. I could fix the latter creating some task in Gruntfile.js using grunt-contrib-copy to do it for me, but that looks like an hack.

Is there a better way?

1 Answers1

1

Because of its flat tree dependencies you should use bower instead, npm is meant for server side. Moreover you don't have to change you module of place, directly link your bower_components/bootstrap/dist/css/bootstrap.css to your project.

bower install --save bootstrap
Frederic Le Feurmou
  • 1,676
  • 1
  • 17
  • 22
  • I'm not sure I understand the point about the "flat tree dependencies". Care to expand further? – Jacopo Notarstefano Nov 28 '14 at 16:23
  • 1
    It means that if two or more of your modules have the same dependency, bower will share this dependency for all these modules. It's great for the client side where your modules size matters, but not for the server side. To summarize use npm for your server side modules and bower for your client side modules. Here is an image to illustrate my words : http://upload.wikimedia.org/wikipedia/commons/f/f9/ECM_trees_1.png And a stack overflow topic about that http://stackoverflow.com/questions/18641899/difference-between-bower-and-npm – Frederic Le Feurmou Nov 28 '14 at 16:30
  • I implemented your solution, then went back and loaded Bootstrap from the `node_modules` directory (https://github.com/jacquerie/portfolio-template/commit/4e8042e12b4183c691a322ce21b92419ebe5b8aa). Adding a new package manager to manage a single component seemed like an overkill to me. – Jacopo Notarstefano Nov 28 '14 at 20:44