Node Js can be installed from brew Or we can download and install manually.
1. Installing node through brew:
- Please execute the below command in terminal to install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Close the terminal and open it again
- Run brew update to update brew to latest version
- Run brew doctor as a safe measure to make sure your system is ready to brew
- Now execute the below command in terminal to install nodeJs
brew install node
2. Installing node manually:
- Please download the latest version of Node Js from http://nodejs.org.
- Double click on the downloaded apk file.
- Click on ‘Continue’ button under installation wizard and complete the installation.
After installing the NodeJs by following either of the above 2 procedures we need to verify whether npm is ready to use.
Now, open another terminal window and type ‘npm’ and hit enter.
If you observe ‘-bash: npm: Command not found’, you need to append npm location to the $PATH environment variable. Please execute the below commands in set $PATH for npm.
1. printf '%s\n' "export PATH=/usr/local/bin:\$PATH" >> ~/.bash_profile 2. printf '%s\n' "export PATH=/usr/local/bin:\$PATH" >> ~/.profile
Your NodeJs is installed and npm is ready to use.