Skip to content

Instantly share code, notes, and snippets.

@hellatan
Last active May 5, 2019 01:38
Show Gist options
  • Save hellatan/a97fa99d9dc4b975701b4567166cd47e to your computer and use it in GitHub Desktop.
Save hellatan/a97fa99d9dc4b975701b4567166cd47e to your computer and use it in GitHub Desktop.
Commands for installing specific node.js versions via homebrew

tl;dr:

~/$ brew unlink node
~/$ brew install node@10
~/$ brew link node@10 --force --overwrite

full output:

~/$
brew install node@10
==> Downloading https://homebrew.bintray.com/bottles/node@10-10.15.3.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/da/da02e50a7340a9607fb2d6a0018dee8f27ef4d81d70c406e70d12c93619ae15b?__gda__=exp=1556998679~hmac=afb32519f4d0328909ebc058f31681fb591eda27df37a4d56adb277f03
######################################################################## 100.0%
==> Pouring node@10-10.15.3.mojave.bottle.tar.gz
==> Caveats
node@10 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have node@10 first in your PATH run:
  echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> ~/.zshrc

For compilers to find node@10 you may need to set:
  export LDFLAGS="-L/usr/local/opt/node@10/lib"
  export CPPFLAGS="-I/usr/local/opt/node@10/include"

==> Summary
🍺  /usr/local/Cellar/node@10/10.15.3: 3,630 files, 45.8MB
~/
brew unlink node
Unlinking /usr/local/Cellar/node/12.1.0... 0 symlinks removed
~/
brew install node@10
Warning: node@10 10.15.3 is already installed and up-to-date
To reinstall 10.15.3, run `brew reinstall node@10`
~/
brew link node@10
Warning: node@10 is keg-only and must be linked with --force

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> ~/.zshrc
~/
brew link node@10 --force
Linking /usr/local/Cellar/node@10/10.15.3...
Error: Could not symlink bin/node
Target /usr/local/bin/node
is a symlink belonging to node4-lts. You can unlink it:
  brew unlink node4-lts

To force the link and overwrite all conflicting files:
  brew link --overwrite node@10

To list all files that would be deleted:
  brew link --overwrite --dry-run node@10
~/
brew link node@10 --force --overwrite
Linking /usr/local/Cellar/node@10/10.15.3... 3592 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"' >> ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment