Straightforward Guide to Installing NodeJS

Table of Contents

Mac

First of all, you need to install xCode and Homebrew. While there is technically a way to install Node without using them, using Homebrew is safer and easier. (If you want to investigate this alternative method, check out the NodeJS documentation.)

To install xCode, go to the Mac App Store, search for ‘xCode,’ click on ‘Get’ and then ‘Install app.’ It’s a rather large download, to the tune of 5.3 GB, so go read a book while waiting for it.

Once it’s done, open xCode and accept any Terms and Conditions. Once it gives you an option start a new projectgo to the Terminal application and run this command to download Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Now, use Homebrew to install NodeJS:

brew install node

Once that’s done, check and ensure that it’s installed correctly. Run node -v & npm -v. If they both return a version number, then you’re done! NodeJS has been installed.

Windows

The Windows installation is relatively straightforward. Just go to the NodeJS website and download the Windows installer. Once you have it on your computer, double-click on the installer and follow the prompts.

Once it finishes, simply restart your computer. Voila!

Linux

If you’re using Linux, you are probably familiar with the concept of running commands in the Terminal. All you need to do is take these commands and run them one by one. Just press Continue whenever it prompts you.

  • If you have an Ubuntu- or Debian-based distribution, run:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
  • If you have a Fedora-based distribution, run:
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum -y install nodejs
sudo yum install gcc-c++ make
  • Finally, if you have an Arch-based distribution, run:
pacman -S nodejs npm

Conclusion

There you have it. You have successfully installed both NodeJS and its package manager, NPM. To read more about installing Node on these and other operating systems, check out the official NodeJS documentation.