Saturday 16 December 2017

gruntjs - Can/should Grunt be used with Bower without Npm?

itemprop="text">


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



Answer





  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.




href="http://blog.nodejitsu.com/package-dependencies-done-right/"
rel="nofollow">http://blog.nodejitsu.com/package-dependencies-done-right/



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...