node -p 'JSON.parse(require("fs").readFileSync("pkg.json","utf8")).version'

Category: Node.js & npm/yarn

node -p 'JSON.parse(require("fs").readFileSync("pkg.json","utf8")).version'

Print the result of a JS expression — -p is like -e but auto-prints the return value

Like -e but also prints the return value. Useful for quickly extracting data in shell scripts.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.