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 use NVM to handle my Node versions. Very simple to set up and easy to use.

```
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

```

To install NVM globally instead, use the following curl command instead of the one above (and presumably don't use the second command but do use the third one)

```
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | NVM_DIR=/usr/local/nvm bash

```

Then use `nvm install stable` (or insert a version number instead of `stable`) to get the latest/a specific version of Node. Use `nvm use stable` (or a specific version number) to use that Node version. Use `nvm ls` to see what Node versions you have installed and `nvm uninstall stable`(or a specific version number) to remove a specific version of Node.

Sources:
[Install](https://github.com/creationix/nvm/blob/master/README.markdown#install-script), [usage](https://davidwalsh.name/nvm)

#### Note

If you are struggling with updating `npm` to the latest stable version because you are stuck at a specific version of `npm` and every time you update it that doesn't work then you can use this method to update `npm` as well. As soon as you install the latest stable version of `node`, `npm` will automatically be updated to its latest stable version.
If using `n` does not work, you can install the latest version of `nodejs` (i. e. version 8) running the following commands:

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

sudo apt-get install -y nodejs

```

Further instructions are [here](https://github.com/nodesource/distributions).