Setup Node Version Manager (NVM) on macOS M1 Silicon

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 giv…


This content originally appeared on DEV Community and was authored by Eric Bishard

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 Mac M1, these are the steps I would encourage you to try.

  1. Navigate to your home directory
cd ~
  1. Create a .zshrc file (if it doesn't exist)
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 (currently Node v17.x).

NOTE: Node versions before v15.x are not necessarily ARM compatible, but it seems that Node has addressed this issue, so if you do install a version prior to v15.x hopefully, you will 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 v16.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

Finallly, to clear the nvm cache to reduce clutter, run:

nvm cache clear

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

This is not widely talked about and the best sources I have found on the subject came from Code Fallacy on YouTube and Michael Baldwin who both have good information on this topic, so much thanks to them where credit is due...


This content originally appeared on DEV Community and was authored by Eric Bishard


Print Share Comment Cite Upload Translate Updates
APA

Eric Bishard | Sciencx (2021-11-14T09:50:41+00:00) Setup Node Version Manager (NVM) on macOS M1 Silicon. Retrieved from https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/

MLA
" » Setup Node Version Manager (NVM) on macOS M1 Silicon." Eric Bishard | Sciencx - Sunday November 14, 2021, https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/
HARVARD
Eric Bishard | Sciencx Sunday November 14, 2021 » Setup Node Version Manager (NVM) on macOS M1 Silicon., viewed ,<https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/>
VANCOUVER
Eric Bishard | Sciencx - » Setup Node Version Manager (NVM) on macOS M1 Silicon. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/
CHICAGO
" » Setup Node Version Manager (NVM) on macOS M1 Silicon." Eric Bishard | Sciencx - Accessed . https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/
IEEE
" » Setup Node Version Manager (NVM) on macOS M1 Silicon." Eric Bishard | Sciencx [Online]. Available: https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/. [Accessed: ]
rf:citation
» Setup Node Version Manager (NVM) on macOS M1 Silicon | Eric Bishard | Sciencx | https://www.scien.cx/2021/11/14/setup-node-version-manager-nvm-on-macos-m1-silicon/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.