How to install Node.js on a Mac OS X 10.12 (All Steps!)

Okay. Node.js install. First, let me say, I’m straight up copying steps from other places, BUT this is TOTALLY different because I’ve patched them all together in one spot for ease of use. Okay, enough funny business.

Here are the places I cribbed such wonderful instructions and Frankensteined them together:

Deep breath. Here we go!

  1. Download and install Apple’s Xcode.
  2. Launch Xcode and agree to the terms. It may install some additional components. Once you agree, then you can close it.
  3. Open your Terminal app (located in Applications > Utilities > Terminal.
  4. Install Xcode’s command line tools:
    xcode-select --install
  5. Reboot in “recovery mode” by restarting your computer and when you hear the start up chime, hold down the “command”+”R” keys until it fully reboots.
  6. Once in Recovery mode, open Utilities > Terminal and run “csrutil disable”. We are going to install Homebrew which needs permissions to the “/usr/local” directory, which Apple restricts.
    csrutil disable
  7. Reboot your computer!
  8. Reopen Terminal.
  9. Set permissions for ‘/usr/local’ by running…
    sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
  10. Reboot in “recovery mode” again.
  11. Once in Recovery mode, open Utilites > Terminal and run “csrutil enable” to make sure we reinstate Apple’s security measures.
    csrutil enable
  12. Reboot your computer
  13. Open Terminal and install Homebrew through the command line.
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  14. Test if Homebrew installed correctly by running…
    brew doctor
  15. Install Node through the command line.

    brew install node
  16. Test to see the node versions
    node -v

    and

    npm -v
  17. Create a test.js with some code in it.
    console.log('I installed Node.js');
  18. Run it with node to prove your install works.
    node test.js
  19. You’re done. Woo hoo!