npm get package.json version code example
Example 1: npm get package.json version
node -pe "require('./package.json')['version']"
Example 2: npm update package.json version field by code
# From 1.0.0 -> 1.0.1
npm version patch
# From 1.0.1 -> 1.1.0
npm version minor
# From 1.1.0 -> 2.0.0
npm version major