How to install Node.js and npm in Linux

Amalu Susan Santhosh
2 min readMar 16, 2018

This is what I’d done after a lot of lookout for the correct steps :)

1.Dependencies: You need to install a number of dependancies before you can install Node.js and NPM.

For Ubuntu or Debian-based Linux distributions, run the following command in your terminal:

sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev

Then select Y to continue and wait for the packages to be installed.

2.Homebrew. Homebrew is a package manager originally for the Mac, but it’s been ported to Linux as Linuxbrew, making installing most open-source software (like Node) as simple as writing: brew install node

You can learn more about Homebrew at the Homebrew website and Linuxbrew at the Linuxbrew website. To install Homebrew for Linux, open your terminal application and paste in the command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

Once Linuxbrew is installed, you’ll need add the following 3 lines to your .bashrcor .zshrc file:

export PATH="$HOME/.linuxbrew/bin:$PATH"
export MANPATH="$HOME/.linuxbrew/share/man:$MANPATH"
export INFOPATH="$HOME/.linuxbrew/share/info:$INFOPATH"
INSTALLATION

Installing Node.js and NPM is pretty straightforward using Linuxbrew, the Linux port of Homebrew. It handles downloading, unpacking, compiling, and installing Node and NPM on your system. After you have Linuxbrew installed, the whole process should only take you a few minutes.

Open up your terminal and type :

brew install node OR brew install -v node

Sit back and wait. Homebrew has to download some files, compile and install them. But that’s it. ( for me it took 21 minutes and 15 seconds)

Testing it out.

Make sure you have Node and NPM installed by running simple commands to see what version of each is installed:

  • Test Node.js. To see if Node.js is installed, type node -v in the terminal. This should print the version number, so you’ll see something like this: v0.10.35.
  • Test NPM. To see if NPM is installed, type npm -v in the terminal. This should print the version number, so you’ll see something like this: 2.1.17

--

--