avatarBen Scheer

Summary

The website provides a step-by-step guide for installing NVM (Node Version Manager) and Node.js on a macOS M1 Silicon in 2022.

Abstract

The article serves as a comprehensive tutorial for software engineers with macOS M1 Silicon computers to install NVM and Node.js. It addresses common issues found in outdated guides by offering clear instructions for creating a .zshrc profile, installing NVM using a cURL command, and setting up Node.js through NVM. The guide also includes a bonus section on enhancing the terminal with oh-my-zsh and integrating NVM with it. The process is designed to be quick and straightforward, ensuring that developers can efficiently set up their development environment.

Opinions

  • The author suggests that having NVM and Node installed is a common requirement for software engineers with Mac computers.
  • Many existing articles on installing NVM and Node are considered outdated or insufficiently detailed, prompting the creation of this updated guide.
  • The author recommends installing oh-my-zsh as an optional step to improve the terminal's aesthetics and functionality, indicating a preference for a more user-friendly command-line interface.
Photo from Aleksander Vlad

How to Install NVM and Node on macOS M1 Silicon in 2022

Get NVM and Node quickly and easily.

If you’re a software engineer with a Mac, having NVM and Node installed is likely a requirement. In 2022, it’s easier than ever to get this all installed and check it off your to-do list.

There are a ton of articles out there about installing NVM and Node, however, many of them are a bit outdated or not detailed enough. To address those gaps, this article makes it easy to get NVM and Node on a new Mac. Let’s dive in!

Step 1: Get NVM

Open a new terminal window. Run the following command to see if you already have a .zshrc profile or not:

ls -a

If you see .zshrc in the list, skip this step. Otherwise, if you don’t see it, that means you don’t have it, and you need to create one by running this command:

touch .zshrc

Now you definitely have a .zshrc profile, which means you can get NVM. Visit this site to find the NVM cURL install command under the section called Install & Update Script. The command looks similar to this:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Copy that command and enter it into your terminal. This installs NVM and makes it available for use.

Since this installation influences your .zshrc profile, you need to run this command to refresh things:

source .zshrc

NVM is installed! You can just run the command nvm to confirm this.

Step 2: Get Node

To install Node, just run this command in your terminal:

nvm install node

Node is now downloaded but you need to run the following command to actually use it:

nvm use node

Step 3: Confirm Everything Works

Okay, it’s time to double-check that everything works. You can run the following commands to make sure you’re using versions Node, NPM, and NVM:

node -v
npm -v
nvm -v

If you’re seeing version numbers pop up for each of these commands, then you’re good to go.

Bonus Round: Get oh-my-zsh

This is optional —but if you want to spruce up your terminal and make it more colorful, I recommend installing oh-my-zsh. Here’s how to install it but also how to get NVM to work with it.

First, find the install command here. It’s the cURL command shown under the section called Install oh-my-zsh now. Copy this command and run it in your terminal. It should look something like this:

$ sh -c “$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Once it installs, exit out of the terminal window and open up a brand new terminal window. If you try running the command nvm, you might notice it doesn’t work. That’s because it’s not set as a plugin. To fix this, there are a couple of things you have to do.

First, open up your .zshrc file to edit it:

vi ~/.zshrc

Use your down arrow key to scroll down in the file until you see plugins=(git). Press the i key to go into edit mode. Adjust your cursor using your arrow keys and then add nvm in the parenthesis so it looks like this: plugins=(git nvm). Make sure there is a space between git and nvm.

When this is done, save and exit this file by doing the following: Press your escape key, then type :wq, and then press enter.

Next, to refresh with your edits, run this command:

source ~/.zshrc

You should be good to go! To test this out, exit out of your terminal window and open up a new terminal window. Once there, run the command nvm and you shouldn’t see any errors.

I hope this was a helpful, clear tutorial on how to install NVM and Node on a new Mac in 2022. Thanks so much for reading. Until next time!

Web Development
Productivity
Business
Technology
Advice
Recommended from ReadMedium