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

15.04aptcurlnodejsupgrade

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.

Best Answer

  • 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.

  • Related Question