Skip to content

Instantly share code, notes, and snippets.

@sillero
Last active July 8, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sillero/5abed49e6243be8d045f4e69e686508b to your computer and use it in GitHub Desktop.
Save sillero/5abed49e6243be8d045f4e69e686508b to your computer and use it in GitHub Desktop.
Set up Mac FE dev environment #node #npm #nvm #vscode #yarn #MacOS
# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Make sure yarn is sans-node
brew uninstall yarn node
brew install yarn --without-node
# Install NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
nvm install --latest-npm
echo "
# place this after nvm initialization in your ~/.zshrc file
# this will automatically load the right node version when you
# enter a diretory with a .nvmrc file
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
" >> ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment