Skip to content

Instantly share code, notes, and snippets.

@tillig
Last active April 22, 2021 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tillig/fea277ef21bf0929d9c64af63f0c50ff to your computer and use it in GitHub Desktop.
Save tillig/fea277ef21bf0929d9c64af63f0c50ff to your computer and use it in GitHub Desktop.
Switch versions of Node.js using Homebrew
# From
# https://medium.com/@katopz/how-to-install-specific-nodejs-version-c6e1cec8aa11
# See node versions
brew search node
# Remove the existing symlinks
brew unlink node
# Install node at specific version
brew install node@12
# Link the new node install
brew link node@12 --force --overwrite
# To revert to node you need to
# - unlink the specific install
brew unlink node@12
# - force reinstall node because `brew link node` does not
# re-link npm, apparently intentionally(?).
# https://github.com/Homebrew/homebrew-core/issues/34475
brew reinstall node
@tillig
Copy link
Author

tillig commented Apr 22, 2021

I've started using the n version manager which works in all shells, unlike nvm.

sudo mkdir /usr/local/n
sudo chown tillig /usr/local/n
n install latest
n list

Note the arrow keys in n don't work in PowerShell but you can use j and k to navigate instead, and that works fine.

@tillig
Copy link
Author

tillig commented Apr 22, 2021

I think if I was on Windows I'd probably use nvm-windows because, again, it's not shell-specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment