npm install bower using -g vs --save-dev

Eric Bishard picture Eric Bishard · Aug 2, 2014 · Viewed 10.6k times · Source

I'm new to node and using npm to both do some node, angular and Express tutorials. I have used bower before in a tutorial. I'm pretty sure I have installed it using -g already as when i run the bower -v command I get back 1.3.3 I am to understand that installing it using -g means, Install this globally so that on the next project I don't have to install it again.

1) Is this correct?

2) When I start working with a new project do I have to initialize bower?

3) Is there any reason I should use install bower --save-dev after I have already installed bower (-g)lobally?

4) What exactly does install bower --save-dev do?

I have searched and get nothing on google or stack over flow when I search "--save-dev".

I really want to understand this and if you help me, it will help me understand installing much more than just bower and how to use those installs. Again, I'm new to the command line for this type of development and new to these technologies, but have some basic understanding.

Answer

SamT picture SamT · Aug 2, 2014

Using the --save and --save-dev flags when installing will add them to the project's package.json. This allows anyone who might develop on or use the project to install the dependencies as needed with a simple npm install command. By contrast, the -g flag is global only to your local machine.