Skip to content

Instantly share code, notes, and snippets.

@djanowski djanowski/nnm
Created Jun 28, 2016

Embed
What would you like to do?
#!/usr/bin/env bash
# `nvm use` the version specified in package.json.
source $(brew --prefix nvm)/nvm.sh
set -eo pipefail
die() {
echo "$@" >&2
exit 1
}
if [[ ! -f package.json ]]; then
die "No package.json found."
fi
NODE_VERSION=$(jq -r .engines.node package.json)
if ! nvm use "$NODE_VERSION"; then
nvm install "$NODE_VERSION"
nvm use "$NODE_VERSION"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.