Installing Node.js on macOS Big Sur using nvm

Photo by Lukas Hellebrand on Unsplash

I recently clean installed macOS Big Sur and is in the process of setting up all my software. As part of the spring cleaning process I wanted to clear out all of the GitHub forks that I accumulated like a snowball.

To help in this process I found delete-github-forks that can bulk delete GitHub forks and this tool is written using Node.js

So I thought it would be a good idea to document how I install node on macOS Big Sur.

Installing nvm

nvm (node version manager) allows you to have multiple versions of node installed and thus help avoid compatibility issues when projects use different versions of node.

Get the latest command line script to be run from https://github.com/nvm-sh/nvm and then run the command in the terminal. It is always a good idea to first read the script before just blindly running it.

The script will make changes to .zshrc so I backup mine first and then install nvm.

Note: If you don’t have a .zshrc file yet then you need to create it first (touch ~/.zshrc)

$ cp .zshrc .zshrc.bak
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

Then I verify the changes made to .zshrc

$ diff .zshrc .zshrc.bak
40,43d39
<
< 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

Relaunch the terminal and verify nvm

$ nvm -v
0.37.2

Installing node

To install the latest version of node.

$ nvm install node

Verify the version of node being used.

$ nvm run node --version
Running node v15.10.0 (npm v7.5.3)
v15.10.0

You can also now just use node directly
$ node --version
v15.10.0

To install a different version of node.

$ nvm install 14.16.0
$ nvm use 14.16.0

List the installed versions.

$ nvm ls

See https://github.com/nvm-sh/nvm for more information on how to use nvm.


1 comment on “Installing Node.js on macOS Big Sur using nvm

Comments are closed.