Skip to content

Instantly share code, notes, and snippets.

@xx4159
Forked from DarrenN/get-npm-package-version
Created January 10, 2020 02:55
Show Gist options
  • Save xx4159/00f55355e8fcd5ecf8a449d03257b976 to your computer and use it in GitHub Desktop.
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