Installing Latest Version of Node.js and NPM

The easiest way to upgrade node.js and npm, in my opinion is to uninstall existing node.js and npm and which can be done with this single command

                                  sudo apt-get remove nodejs

Now we need to install latest version of nodejs and npm and both can be achieved with single command as in the previous case. But  before that we need to update the repossitory. For that try running the following terminal command

curl -sL https://deb.nodesource.com/setup | sudo bash -

If you don’t have “curl” installed in your system, you will have to do that with the following command

sudo apt-get install curl

Now  finally it is time to run the command  sudo apt-get install nodejs      to install nodejs and npm in a single go (installing nodejs will install npm also).

Now check the node js and npm versions using the command
                            node -v
                            npm -v

You can see that both are of the latest versions

Ref :https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

Advertisements