This question already has an answer here:

I installed Nodejs via package

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

Then I check version of nodejs and npm

nodejs -v
npm -v

Current version of nodejs are v4.4.2 LTS and v5.10.1 stable. What's wrong?

marked as duplicate by Anwar, Kaz Wolfe, Zanna, Byte Commander, Android Dev May 8 '17 at 19:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can simply download nodejs binaries for linux from https://nodejs.org/en/download/ (preferably LTS version 4.4.3). Unzip it and place it anywhere you want (say /opt folder). Now you can link to bin/node and bin/npm commands in your ~/.bashrc file using alias

alias node='/opt/node-v4.4.3/bin/node'
alias npm='/opt/node-v4.4.3/bin/npm'

Installing using Package Manager

Execute the following commands to install the latest Node in ubuntu sudo apt-get install python-software-properties curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install nodejs

Installing Using Pre-Built Binary Package in Custom Location

  1. Download the Latest version of Node from here.
  2. Put the tarball file in the desired location, where you want to put the binary file.

  3. Update the system path to have the binary of Node.

  4. According to the desired location we can change global package installation by executing the following commands:

npm config list #This gives us information about our install

npm config get prefix # give information about current global installation location.

npm config set prefix=</path-to-download-the-packages>

You may have to put the path of nodejs to the system path.

Not the answer you're looking for? Browse other questions tagged or ask your own question.