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: 
Using [nvm](https://github.com/creationix/nvm) is preferred method. First install nvm:

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

```

Then install nodejs:

```
nvm install node

```

Now on, you can easy switch versions of node.
The selected [answer](https://askubuntu.com/a/480642/247771) did not work for me, I tried restarting terminal and PC but no success.

I have installed (as recommended in the docs) npm and node with node version manager. In this case, one can update node and npm simply with

```
nvm install stable

```

I explained [here](https://stackoverflow.com/a/59575266/2311074) how to switch to reinstall with node-verion-manager if you have installed npm/node with Node installer.