I'm using a Debian/Ubuntu based distribution (specifically, AWS Ubuntu 16.04) and trying to install NPM through apt-get
.
My Angular 2 application needs a higher version than 3.9.x of NPM, but the default version which is getting installed is 3.5.2 using sudo apt-get install npm
on AWS Ubuntu 16.04. I'm trying to update NPM, but it's not getting upgraded to 4.6.1 (latest) from 3.5.2.
How do I install/update NPM so that I've got the latest version?
The reason WHY the package manager has old versions of the binaries is due to the fact it takes time for the maintainers of the provided packages to properly build and test new ones with updated versions. The good thing is that you can consume and install packages from other repositories (ppa).
Method 1: Using npm update command to update the node package manager. Method 2: Using npm@latest command to update the node package manager. Method 3: Using PPA repository (only for Linux). Method 4: Using cache cleaning & stable installing (only for Linux).
type 'hash -r' on your server bash.
Then check your 'npm -v' again
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With