24 May 2016

Bower: Client Side Package Manager

Bower (http://bower.io/) is a client side package manager.
Prerequisite: Node.js package manager (npm)

Note that this is usually used to manage client (application/runtime) dependencies, whilst npm is used for the dev dependencies. Bower uses a flat dependency structure (i.e. one version of each package) for minimal client download/conflict whilst npm is focused on reliability so may install multiple versions of the same package. Some people consider that Bower is unecessary, and instead you can simply use npm. e.g. https://gofore.com/stop-using-bower/
  • Install:
    • npm install -g bower --save
    • npm install bower --save
  • Config Files: bower.json configures your packages, and .bowerrc configures the bower client
    • bower.json: bower init --yes
    • .bowerrc
  • Update: npm update -g bower
  • Packages:
    • Search: bower search <package_name>
    • Version: bower info <package_name>
    • Install: bower install <package_name> <optional version no.> --save
      NB: the --save option adds them to the package.json file
    • List installed: bower list
    • Update installed: bower update --save
      NB: to update the bower.json you need to use 'install' and do one pacakge at a time e.g.
      bower install --save jquery
    • Unistall: bower uninstall bootstrap --save
    • Cleanup: bower cache clean; bower install --force; bower prune
    • Initialize: bower init

No comments:

Post a Comment