How to install nodejs on Mac

How to install nodejs on Mac

First step is to install "Homebrew" on Mac machine.
About Homebrew:
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste.

Paste the below command in a macOS Terminal prompt.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Installation successful!
After successful installation execute below steps.
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/{username}/.zprofile
Note: {username} - replace with current mac user name.
eval "$(/opt/homebrew/bin/brew shellenv)"

Now once done with the above steps,  we can go ahead and install node using Homebrew. Run below command:
brew install node

That's it now we are done with successful installation of node on mac.
To know the node and npm version, run below command:
node -v -------> This will print the node version.
npm -v -------> This will print the npm version.