7

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.

  • You'll want to figure out where your current version of Node is coming from. which nodejs will tell you that. Then, run apt-get remove... again and see what the output of which nodejs is after attempting to remove it. – Michael Martin-Smucker Dec 25 '15 at 14:34
  • which nodejs isn't found. It uninstalls it completely when I use remove. – Jack_Hu Dec 30 '15 at 13:43
15

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.

6

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.

  • 1
    Awesome! Glad you found something that works. NVM is my preferred way of installing Node on Ubuntu as well. – Michael Martin-Smucker Dec 31 '15 at 15:23
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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