Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why only outdated version of NPM is available on Debian/Ubuntu?

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?

like image 651
Raj Bhatia Avatar asked May 21 '17 10:05

Raj Bhatia


People also ask

Why is Ubuntu NodeJS so old?

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).

How do I update npm only?

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).


2 Answers

type 'hash -r' on your server bash.

Then check your 'npm -v' again

like image 172
StefanBob Avatar answered Sep 25 '22 12:09

StefanBob


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.

like image 21
Aurora0001 Avatar answered Sep 25 '22 12:09

Aurora0001