0

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
v0.10.25
npm -v
1.3.10

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

edwinksl
  • 23,789
Loint
  • 131

2 Answers2

0

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'
edwinksl
  • 23,789
sbharti
  • 256
0

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.

Bidyut
  • 759
  • 7
  • 14