25

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.

Erki M.
  • 5,022
  • 1
  • 48
  • 74
dev73
  • 369
  • 1
  • 4
  • 7

3 Answers3

38

Use

npm list --depth=0

You can also use grep to look for a specific package

npm list --depth=0 | grep grunt-contrib-compass

command.png

There is an npm ls alias, for short.

bevacqua
  • 47,502
  • 56
  • 171
  • 285
10

Perhaps you can try this, it worked for me.

grunt -version
Imran Khan
  • 143
  • 2
  • 8
1

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"
Community
  • 1
  • 1
Ben
  • 10,106
  • 3
  • 40
  • 58