Reputation: 369
Just wondering what is the command to verify the currently installed version of any grunt module already installed using command line. For example
grunt-compass -v
Or
grunt-compass --version
do not work.
Upvotes: 25
Views: 55531
Reputation: 48486
Use
npm list --depth=0
You can also use grep
to look for a specific package
npm list --depth=0 | grep grunt-contrib-compass
There is an npm ls
alias, for short.
Upvotes: 39
Reputation: 10146
With Python you can do something like this, in the root of your project, remembering to substitute grunt-contrib-compass for any other package installed with npm.
cat node_modules/grunt-contrib-compass/package.json | python -c "import json, sys; print json.load(sys.stdin)['version']"
This is not my code, I've adapted it from here - Parsing Json data columnwise in shell - but I've tested it and it works. :-)
If you'd rather a node/grunt solution, you can have a look at my answer here. It's based on the project's package.json
, but you could adapt that to use one in the node_modules
directory.
Edit: After reading Nico's answer, you could transform that output with sed to print just the version number, like so:
npm list --depth=0 | grep grunt-contrib-compass | sed "s/[^0-9\.]//g"
Upvotes: 1