I'm new to using npm and bower, building my first app in emberjs :).
I do have a bit of experience with rails, so I'm familiar with the idea of files for listing dependencies (such as bundler Gemfile)
Question: when I want to add a package (and check in the dependency into git), where does it belong - into
Npm and Bower are both dependency management tools. But the main difference between both is npm is used for installing Node js modules but bower js is used for managing front end components like html,css,js etc.
The fact that npm provides some packages which can be used in front-end development like
These lines add more meaning
Bower, unlike npm, can have multiple files (e.g. .js, .css, .html, .png, .ttf) which are considered the main file(s). Bower semantically considers these main files, when packaged together, a component.
Please Note grunt plugin is also an npm package.
When I want to add a package (and check in the dependency into git), where does it belong - into package.json or into bower.json
It really depends where does this package belong to. If it is a node module(like grunt,request) then it will go in package.json otherwise into bower json.
When should I ever install packages explicitly like that without adding them to the file that manages dependencies
It does not matter whether you are installing packages explicitly or mentioning the dependency in .json file. Suppose you are in middle of node project and you need another project say
request, you have two options:
npm install --save request
--save options adds the dependency to package.json file as well. If you don't specify
--save option, it will only download the package but json file will be unaffected.
You can do this either way, there will not be a substantial difference.