npm will set all kinds of useful environment variables for you. To see what gets set, add the following to your package.json:
{
"scripts": {
"check-env": "node -e 'console.log(process.env)' | grep npm"
}
}...and then run $ npm run check-env.
Lots of information about your dependencies, configuration, node and npm versions, and, interestingly npm_package_gitHead, which is the SHA of the current git HEAD.