Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out what version of a bower package is actually installed?

Normally a bower.json file specifies some dependencies, but these are typically expressed so that they allow a range of versions of a bower package to be used (e.g. >=1.0, which means anything higher than version 1.0).

I have an automated process which needs to find what version of a bower package is actually installed on this system right now.

How can I find this out programmatically (just the version itself), ideally using standard Unix command line tools / the bower command?

bower info <thepackagename> does not show this - it shows information about what is currently available from the bower repository (for example, even if I do bower info apackageIdonthaveinstalled it will still show a valid JSON structure containing a version number).

cat bower_components/thepackagename/bower.json | node_modules/json/lib/json.js version works for some packages (assuming the npm package json is installed), but not all (e.g. jquery 2.2.0's bower package does not contain a bower.json).

like image 867
Andrew Ferrier Avatar asked Feb 12 '16 16:02

Andrew Ferrier


People also ask

How do I update my bower package?

If there aren't that many bower packages you have installed, try writing bower install [package_name] --save . This will just update your bower. json file.

Where does bower install packages?

Installed packages will be placed in a bower_components directory. This is created in the folder which the bower program was executed. You can change this destination using the configuration options in a . bowerrc file.

What bower install does?

Bower doesn't concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies. To get started, Bower works by fetching and installing packages from all over, taking care of hunting, finding, downloading, and saving the stuff you're looking for.


2 Answers

Here's a grep command to do that: grep "version\"\:" bower_components/thepackagename/.bower.json

Also, a command to see versions of all bower components for the project - this list can be a handy CI artefact: grep "version\"\:" bower_components/*/.bower.json enter image description here

like image 162
Artem Vasiliev Avatar answered Oct 17 '22 11:10

Artem Vasiliev


Have you ever tried "bower list --json=0 --offline".

It would list all bower packages info.

like image 27
yujohnnyzhou Avatar answered Oct 17 '22 10:10

yujohnnyzhou