Unable to update Node JS - keeps returning to old version [Ubuntu 15.04]

I'm unable to update nodejs, and I can't see why.

If I were to make a guess, I'd say that I have two repositories listed in apt-get, that both contain a nodejs package.

Here's what I've done:

Remove old version:

sudo apt-get remove --purge nodejs npm

Then, going by https://github.com/nodesource/distributions#installation-instructions, I've run:

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -

And then:

sudo apt-get install -y nodejs

I then run:

nodejs -v

Which returns:

v0.10.25

Can anyone explain what's going wrong? And how I can remedy this situation?

Many thanks.


Using the nvm (node version manager) is the best option to update the default version of node.

  1. install or update nvm:

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
    

    or

    wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
    
  2. After successful installation, close the terminal and open a new terminal. List the version of nodejs available:

    nvm ls-remote
    

    This will list the available versions of nodejs.

  3. Select the version you want to install:

    nvm install xxxxxx
    
  4. Check the version:

    node -v
    

Hope this helps as a step by step guide.


In the end I was sick of getting nowhere.

As a fix, I decided to use nvm (node version manager).

It's super simple to install, setup and use. Took less than 3 minutes to get back up and running with nodejs version 5.

https://github.com/creationix/nvm

I'm writing this for completeness.


I always use n to do update, upgrade and remove node versions. Note that you might have to use sudo, depending on your configuration.

$ npm install -g n

Use or install the latest official release:

$ n latest

Use or install the stable official release:

$ n stable

Use or install the latest LTS official release:

$ n lts

Removing Versions

$ n rm 0.9.4 v0.10.0