Чтобы обновить npm, вам нужно обновить nodejs до последней версии, которая включает в себя npm
. В debian stretch и jessie используйте этот скрипт:
#install prerequisites
apt-get install apt-transport-https curl git lsb-release -y
#Install NodeJS from external repositories
DISTRO=$(lsb_release -c -s)
if [ "$DISTRO" == "stretch" ]
then
DISTRO="jessie"
fi
if curl -f "https://deb.nodesource.com/node_7.x/dists/$DISTRO/Release" >/dev/null
then
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
echo "deb https://deb.nodesource.com/node_7.x $DISTRO main" > /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_7.x $DISTRO main" >> /etc/apt/sources.list.d/nodesource.list
apt-get update
# comment out the following line, if you installed nodejs 7 already (check with `apt-cache policy nodejs`)
apt-get remove nodejs nodejs-legacy npm
apt-get install nodejs -y
else
echo -e "Your distribution is not supported by NodeJS. \nYou have to install a recent NodeJS version (>=4) manually. "
fi
В Ubuntu вы можете использовать этот скрипт с https://deb.nodesource.com:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
см. Источник сначала в https://deb.nodesource.com