Skip to content
Solomon Defi edited this page Oct 12, 2021 · 1 revision

Node Version Manager (NVM)

Install NVM on MacOS (Default Shell)

  1. Install NVM with brew

    # Uninstall existing NodeJS, if present
    brew uninstall --ignore-dependencies node  
    brew uninstall --force node 
    # Install NVM
    brew upgrade
    brew install nvm
    mkdir ~/.nvm
  2. Edit environment file

    vi ~/.bash_profile 
    ---
    export NVM_DIR=~/.nvm 
    source $(brew --prefix nvm)/nvm.sh
  3. Reload shell environment

    source ~/.bash_profile

Install Node versions

# Install latest LTS stable
nvm install 14
nvm ls
---
->     v14.17.5
        v16.6.2
default -> 14 (-> v14.17.5)
...

Upgrade NPM to the latest

Node v14 installs NPM v6. To upgrade to the latest working for the current node version v7:

nvm install-latest-npm 
npm -v
---
7.20.6

Misc

# See all available versions
nvm ls-remote
# See locally installed versions
nvm ls
# Switch between versions
nvm use 14
nvm use default
...
# Set the default version to LTS
nvm alias default 'lts/*'
Clone this wiki locally