
What is node.js?
Node.js is a popular open source JavaScript platform used for the creation of application environments.
There are a couple different ways to install node.js and in this article we’ll explain how to do so using the homebrew utility.
Upon installing node.js using homebrew it will also install the node package manager (npm) which is a tool used to manage packages needed for projects created in node.js.
What is homebrew?
Homebrew is a package manager created for Mac OS but also works on Linux operating systems as well.
It is used for the installation of open source software such as node.js which allows you to create an application environment.
With homebrew we’re able to use the ‘brew’ command in terminal to install open source community software.
How to install node.js with homebrew on Linux
Before we begin, we’ll need to also have homebrew installed on our Linux system.
If you already have this utility installed feel free to move onto Step 4.
1. Install homebrew on Linux
Before proceeding, this should be completed as a non root user account.
As your non root user, enter in the following command into terminal to begin the installation script of homebrew:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You will be prompted for your users password as well. Once entered in the install will begin.

After inputting your password you’ll need to press enter once more when prompted in order to continue:

2. Set the path for Homebrew
After the install has completed you will need to setup the path in your users .profile file. This file is located in your home directory at /home/username/.profile (shown below):
$ echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/username/.profile

After completing the above just make sure you are within your users home directory.
If needed just run the following to change your present working directory to that location:
$ cd ~
After changing your present working directory to your users home directory use the following command to finish things up:
$ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

3. Use brew doctor to verify your installation of homebrew
Now that we’ve installed homebrew lets verify everything went correctly by entering in the following command:
$ brew doctor
We should see the following output which indicates brew is ready for use:

4. Use homebrew to install node.js and npm
Now that we have homebrew installed we can proceed to use ‘brew node install’ to add node.js and npm onto our Linux system.
The installation of node.js and npm can be done by entering in the following command:
$ brew install node
Once it completes you should see the following output:

5. Confirm the versions of both node.js and npm to verify your install
Now that the installation of node.js is finished lets check our versions of both node.js and npm.
Use the following command to confirm the current node.js version installed:
$ node -v
Use the following command to confirm the current npm version installed:
$ npm -v

Leave a Reply