dev73
dev73

Reputation: 369

How can I find out the version of an installed grunt module?

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

Answers (3)

Imran Khan
Imran Khan

Reputation: 153

Perhaps you can try this, it worked for me.

grunt -version

Upvotes: 10

bevacqua
bevacqua

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

command.png

There is an npm ls alias, for short.

Upvotes: 39

Ben
Ben

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

Related Questions