Wednesday, February 9, 2022

How to install node using Brew

This article talks about some simple steps to follow to install node using Brew. Though there are many other ways to do it but the method described below uses nvm to install it and is one of the best method available till date.

Note: Before you proceed, ensure that Brew is installed. To install it follow the link above.

Step 1: Install NVM by running this command

brew install nvm

Step 2: Create a directory for NVM

mkdir ~/.nvm

Steps 3: Create an export in .zshrc to execute nvm command directly, add it to PATH and restart shell

export NVM_HOME="$HOME/.nvm"
    [ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && . "$(brew --prefix)/opt/nvm/nvm.sh" # This loads nvm
    [ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && . "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
export PATH=$NVM_HOME:$PATH

Step 4: Install node

Use this command for specific version

nvm install <version>

User this command to install the latest version

nvm install node

Step 5: Check the version of node installed

node -v
npm -v

Note: Whenever you install any version of node through nvm command it automatically makes it the default version.

Steps to change the version used by nvm

  1. List all versions which nvm has
    nvm list
  2. Change the version
    nvm use <version>

How to install node using Brew

This article talks about some simple steps to follow to install node using Brew . Though there are many other ways to do it but the method ...