Why only outdated version of NPM is available on Debian/Ubuntu?
You're getting version 3.5.2 of npm, because that's the version in the repositories. Debian and Ubuntu are typically terrible at keeping up with Node and npm's fast rate of development, so you'll often find the packages are out of date, and aren't much use to you.
Some Debian distributions (e.g. Jessie) only have npm v1.4.21, which is even more out of date. Incidentally, Debian Jessie is the version upon which Raspbian Jessie, the RPi distribution, is based.
Instead, follow the instructions given on the Node.js website:
Node.js is available from the NodeSource Debian and Ubuntu binary distributions repository (formerly Chris Lea's Launchpad PPA). Support for this repository, along with its scripts, can be found on GitHub at nodesource/distributions.
NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 6.x on older distros.
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs
Alternatively, for Node.js v7:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs
The nodejs
package provided by NodeSource includes npm. Simply install that, and you'll be ready to go with the latest version.
type 'hash -r' on your server bash.
Then check your 'npm -v' again
Upgrade npm:
$ sudo npm install -g npm@latest
$ reboot
$ npm -v
Complete installation:
$ sudo apt install nodejs
$ sudo apt install npm
$ npm -v
npm version: 3.5.2
Then upgrade:
$ npm install -g npm@latest
$ reboot
$ npm -v