24

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.
  • 4,854
  • 1
  • 47
  • 71
dev73
  • 339
  • 1
  • 3
  • 6

3 Answers3

36

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
  • 45,496
  • 53
  • 165
  • 281
7

Perhaps you can try this, it worked for me.

grunt -version
Imran Khan
  • 113
  • 1
  • 7
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
  • 9,978
  • 3
  • 39
  • 58