Question: I have installed nodeJS on Ubuntu with following code 

```
sudo apt-get install nodejs

```

Since I am a new user for ubuntu I also ran this code too

```
sudo apt-get install npm

```

Now when I type 

```
 nodejs --version

```

It shows 

```
v0.6.19

```

I checked and saw latest nodeJS version is `0.10.26` 

How can I update my version of nodeJS to `0.10.26`?

I tried with 

```
 sudo apt-get install <packagename>
 sudo apt-get install --only-upgrade <packagename>

```

but no luck.

Answer: 
I also recommend using [nvm](https://github.com/nvm-sh/nvm) instead, and also removing the already installed version to avoid conflicts in the terminal

```
sudo apt purge nodejs npm

```

then install nvm and use it

[Video Explanation](https://youtu.be/OT7QOFvs9Lk)
=================================================

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

```

to [download and install nvm](https://github.com/nvm-sh/nvm)

```
nvm install node

```

should download and install the latest version of node.

To update node later on just do

```
nvm install node
nvm alias default node

```
If you are behind a proxy, maybe you could get this error when you run 'sudo n stable':

```
Error: invalid version

```

You have to set the env variables like this:

```
export HTTP_PROXY=http://your-proxy-url:port
export HTTPS_PROXY=http://your-proxy-url:port

```

And then run the command passing these variables to the root user:

```
sudo -E n stable

```