Skip to content

Instantly share code, notes, and snippets.

@xx4159
Forked from DarrenN/get-npm-package-version
Created January 10, 2020 02:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xx4159/00f55355e8fcd5ecf8a449d03257b976 to your computer and use it in GitHub Desktop.
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@xx4159
Copy link
Author

xx4159 commented Jan 10, 2020

npm view <name> version

https://docs.npmjs.com/cli/view.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment