I’m trying to relearn how to use Node after years of inactivity, and for some reason installing it has been the biggest pain. It should be pretty straight forward: go to nodejs.org, download the official package and install it on your computer, right?
Installing Node straight from nodejs.org will not set it’s permissions properly for when you want to install a command-line tool or do something that requires admin permission down the line. This along with several other annoying little tidbits is what makes programming such an annoying task for newcomers. Everything has to be set-up just so or the system won’t work.
So here are the step-by-steps on how to install Node on your Mac.
- NOTE - I installed https://ohmyz.sh/ to enhance the stock terminal app. So I’m adding the extra step involved with having zsh installed.
Step 1: Install Node Version Manager or NVM
This will ensure you have the right permissions and versions of Node. (For all the info about NVM go here: https://github.com/nvm-sh/nvm#installation-and-update)
Copy and paste this in your terminal (this is the latest version as of 11/06/2019):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
Run that script and wait for it to finish. Then verify the installation with this command:
command -v nvm
If it is properly installed you should get “nvm” as a return. If you don’t get “nvm” as a return, follow the troubleshooting steps in the github source page above. In my case it failed to display anything, after a little digging I realized the cause was my zsh install. I added “source ~/.zshrc” to the end of my .zshrc file and that solved it.
Step 2: Install Node with NVM
In your terminal type in:
nvm install node
Rejoice, your computer now has Node installed with the right permissions.