Set Up NVM and NPM on MacOS

Install NVM

Tech Notes

--

first run these commands to install nvm with Homebrew

brew update
brew install nvm

here’s my output:

==> Downloading https://ghcr.io/v2/homebrew/core/nvm/manifests/0.39.5
######################################################################### 100.0%
==> Fetching nvm
==> Downloading https://ghcr.io/v2/homebrew/core/nvm/blobs/sha256:2290c2b0f95c6b
######################################################################### 100.0%
==> Pouring nvm--0.39.5.all.bottle.tar.gz
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm

Add the following to your shell profile e.g. ~/.profile or ~/.zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/opt/homebrew/Cellar/nvm/0.39.5 will destroy any nvm-installed Node installations
upon upgrade/reinstall.

Type `nvm help` for further information.
==> Summary
🍺 /opt/homebrew/Cellar/nvm/0.39.5: 9 files, 192.8KB
==> Running `brew cleanup nvm`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
ashley@Ashleys-MacBook-Pro WebWorldWindTS % dir ~/.nvm
ls: /Users/ashley/.nvm: No such file or directory

notice it says we need to make a .nvm folder in the home dir so we do that next:

mkdir ~/.nvm

add the following lines to ~/.zshrc like it says as well


export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion

now refresh your terminal

source ~/.zshrc

That’s it. The NVM has been installed on your macOS system. Go to next step to install Node.js versions with the help of nvm.

Install Node

--

--