Skip to content

Instantly share code, notes, and snippets.

@colbydauph
Last active January 3, 2018 05:32
Show Gist options
  • Save colbydauph/1476d2425639c13da3ff5580eae06321 to your computer and use it in GitHub Desktop.
Save colbydauph/1476d2425639c13da3ff5580eae06321 to your computer and use it in GitHub Desktop.
Read package and node versions via npm scripts

package.json

"engines": { "node": "8.9.1" },
"scripts": {
  "version": "echo $npm_package_version",
  "node-version": "node -p 'require(\"./package.json\").engines.node'"
}

usage

$ npm run --silent version
$ npm run --silent node-version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment