4

I am a little confused about the use of Npm, Bower and Grunt. My objective is to install frontend packages (e.g.: bootstrap) for my front-end project and have Grunt set up to automate build tasks.

I have been using Npm in the past and I understand that it works with the package.json file, while Bower works uses the bower.json file. In this case, I installed Grunt with Bower (not Npm), however I realised that in order to run Grunt I still need to add the package.json file.

  • Should I have been using Bower to install Grunt at the first place ?
  • Does my project always need the package.json file to use Grunt? And if so, are there any good practices for dealing with the duplication between the bower.json and package.json files. (name, version of the app, etc…)

Thanks

Crocodile
  • 5,724
  • 11
  • 41
  • 67

1 Answers1

4
  1. grunt (grunt-cli) is command line task runner, not frontend library :), so installing it via bower is strange, but possible due to the fact that bower is using npm as base repository :)
  2. package.json store all tool dependencies in your project - like bower or grunt

In frontend development bower should be handling css/js libraries in your app like jQuery, Angular.js, Bootstrap. NPM is for node.js extensions/utilities like grunt, karma devDependencies.

http://blog.nodejitsu.com/package-dependencies-done-right/

Rafał Warzycha
  • 561
  • 3
  • 18
  • So in other words I always need both the bower.json and the package.json file for projects which use Grunt and front-end libraries loaded by Bower? – Crocodile Jan 16 '15 at 15:54
  • Yep. It's most common setup. But you can always use npm only - because bower use npm as base. :) - for example if you to to bootstrap https://www.npmjs.com/package/bootstrap you can read that installation can be done via bower or npm or manually. – Rafał Warzycha Jan 16 '15 at 16:06