Skip to content

Instantly share code, notes, and snippets.

@httpJunkie
Last active November 22, 2021 00:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save httpJunkie/08a207e57eefceda01d6f7ceb59b6c54 to your computer and use it in GitHub Desktop.
Save httpJunkie/08a207e57eefceda01d6f7ceb59b6c54 to your computer and use it in GitHub Desktop.
Install Node/NVM on Mac M1

As a web developer these days, we typically need to be able to switch versions of Node on the fly, for this we want to install Node Version Manager on a clean install of our machine, we don't want to start by installin Node on it's own as this will give us a single version of Node (whichever we decide to install)

If you install Node first and then try to install NVM, things can get complicated, so if you have already installed Node, my suggestion is to completely remove it before installing NVM.

As well, NVM is explicitly not supported when installed via homebrew - the only correct way to install it is with the install script in NVM's Readme.

So if you have a brand new Mac M1 these are the steps you need to go through.

  1. Navigate to your home directory
cd ~
  1. Create a .zshrc file
touch .zshrc
  1. Install NVM using the curl command found on the NVM Readme
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

This last command will update your .zshrc file to look like the following:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  1. Install Node using NVM
nvm install node

This will install the latest version of Node, in my case it setup Node v 17.x, to setup alternate version we can specify by version or --lts

NOTE: Node version before v 15.x are not necessarily ARM compatible, but it seems that Node has addressed this issue, so if you do install a version prior to v 15.x You should not need to use Rosetta to run.

  1. Install LTS version of Node
nvm install --lts

Running this command installed the current LTS at the time of this GIST which is v 16.x, I think I will try to stick with this version or better when developing, however; that's the beauty of NVM is that if I need and older version it's easy to switch!

  1. List the versions of Node I have installed
nvm ls
  1. Select an alternate version that I have installed
nvm use 16

or

nvm use --lts

Those will both allow me to use the LTS version we just installed! Hope that helps, Happy Noding~!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment