Get package.json version from CLI

Using NPM

npm info . version
npm info /my/npm/project/path/ version

Use the npm info command to point to the folder where your package.json resides.

Using Node

node -p -e "require('./package.json').version"

The -p argument prints the result and the -e argument expects executable JS to follow it. This one is also helpful for getting specific properties from any JSON file.

Git -Xours -Xtheirs arguments

Git provides a helpful argument to prefer one branch or the other to “clobber” merge conflicts:

git merge main -Xours
git merge main -Xtheirs

I always get confused what the “X” means. I always assume “X” means mark which branch to clobber. Like “X” out their branch. Or “X” out our branch. Please wipe this mnemonic from your brain!

“X” means “PREFER”

“PREFER” the changes in their branch (-Xtheirs) or “PREFER” the changes in our branch (-Xours).

Jeez!

Links