Skip to content

Instantly share code, notes, and snippets.

@aendra-rininsland
Created March 6, 2017 14:20
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 aendra-rininsland/cf153aeba6ca414219b47e7955beb75d to your computer and use it in GitHub Desktop.
Save aendra-rininsland/cf153aeba6ca414219b47e7955beb75d to your computer and use it in GitHub Desktop.
Simple bash script that attempts to fix NodeJS using n via Homebrew on OS X
#!/bin/bash
echo "Running Ændrew's Node Fixer Script"
if (( $(stat -f %u /usr/local) == 0)); then
echo "Fixing /usr/local permissions"
sudo chown -R $USER:"$(id -gn)" /usr/local
fi
echo "Install Node LTS"
if hash n 2>/dev/null; then
n lts
else
echo "You need to install n"
if hash brew 2>/dev/null; then
brew update && brew install n
n lts
else
echo "You also need to install Homebrew"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
if hash xcode-select 2>/dev/null; then
brew update && brew install n
n lts
else
echo "You *ALSO* need to install XCode, which is more than I can do"
echo "Please talk to somebody in #graphics-dev!"
fi
fi
fi
echo "Installing latest npm"
npm i -g npm@latest
echo "Done! Try what you were doing before again. :)"
echo "Any problems? Give @andrew.rininsland a shout!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment