DEV Community

Rich
Rich

Posted on • Originally published at goingserverless.com on

Install nvm and Node.js for macOS 11

The Node Version Manager is an easy to way to run multiple versions of Node. Having upgraded to macOS 11 recently I found that I had accidentally installed a Node using Homebrew and I needed to get nvm working again.

The process was fairly simple.

Uninstall the Homebrew Node:

brew uninstall node
Enter fullscreen mode Exit fullscreen mode

Try to install the Homebrew nvm:

brew install nvm
Enter fullscreen mode Exit fullscreen mode

Ok, this didn't work so well:

######################################################################## 100.0%
Error: Your Command Line Tools (CLT) does not support macOS 11.
It is either outdated or was modified.
Please update your Command Line Tools (CLT) or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

Error: An exception occurred within a child process:
  SystemExit: exit
Enter fullscreen mode Exit fullscreen mode

I knew I was running the latest version of everything so I jumped straight to:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Enter fullscreen mode Exit fullscreen mode

With that done I could finally install nvm:

brew install nvm
Enter fullscreen mode Exit fullscreen mode

I then cleaned out my old .nvm folder and created a new one:

rm -rf ~/.nvm && mkdir ~/.nvm
Enter fullscreen mode Exit fullscreen mode

As I switched from bash to zsh when upgrading to macOS 11 I had to add some lines to my ~/.zshrc:

export NVM_DIR="$HOME/.nvm"
[-s "/usr/local/opt/nvm/nvm.sh"] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[-s "/usr/local/opt/nvm/etc/bash_completion.d/nvm"] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
Enter fullscreen mode Exit fullscreen mode

Before continuing I ran the source command but you could simply restart your shell:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

It was now time to install the version of Node I required:

nvm install v14.16.0
Enter fullscreen mode Exit fullscreen mode

Finally, check that Node is installed correctly.

node --version
Enter fullscreen mode Exit fullscreen mode

Top comments (0)