Install node with nvm then brew

Install Node.js first with nvm (a node version manager like n):

$ curl -o- | bash
$ source ~/.zshrc # ~/.bashrc
$ nvm install [email protected]

The node binary can be found at:

$ which node # command -v node

Now install Node.js with homebrew:

$ brew install [email protected]
$ brew link [email protected] --overwrite --force

However, the default node binary is still coming from nvm:

$ nvm ls
-> v8.15.0

To use the node binary installed by brew, you’ll need to pass the --no-use option to the nvm startup script:

# edit line in your shell configuration (e.g., ~/.zshrc or ~/.bashrc)
-[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
+[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" --no-use  # This loads nvm

To verify that you’re using the brew installed node binary:

$ nvm ls
->  system
$ which node

A nice benefit is that this speeds up the time for shell session creation.