If you agree to install jq, you can use the JSON output of npm list
.
npm -j ls <package-name> | jq -r .version
or, if you want to be verbose
npm --json list <package-name> | jq --raw-output '.version'
For instance:
$ npm -j ls ghost | jq -r .version
0.4.2
Also, the JSON format is slightly different for global packages, so you'll need to change the query.
For instance:
$ npm -j -g ls | jq -r .dependencies.ghost.version
0.4.2