为什么 Debian/Ubuntu 上只能使用过时的 NPM 版本? [英] Why only outdated version of NPM is available on Debian/Ubuntu?

查看:77
本文介绍了为什么 Debian/Ubuntu 上只能使用过时的 NPM 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于 Debian/Ubuntu 的发行版(特别是 AWS Ubuntu 16.04)并尝试通过 apt-get 安装 NPM.

I'm using a Debian/Ubuntu based distribution (specifically, AWS Ubuntu 16.04) and trying to install NPM through apt-get.

我的 Angular 2 应用程序需要高于 3.9.x 的 NPM 版本,但在 AWS Ubuntu 16.04 上使用 sudo apt-get install npm 安装的默认版本是 3.5.2.我正在尝试更新 NPM,但它没有从 3.5.2 升级到 4.6.1(最新).

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.

如何安装/更新 NPM 以便获得最新版本?

How do I install/update NPM so that I've got the latest version?

推荐答案

您将获得 npm 3.5.2 版,因为这是 存储库.Debian 和 Ubuntu 在跟上 Node 和 npm 的快速开发速度方面通常很糟糕,因此您经常会发现这些软件包已经过时,对您没有多大用处.

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.

某些 Debian 发行版(例如 Jessie)只有 npm v1.4.21,这更过时了.顺便提一下,Debian Jessie 是 RPi 发行版 Raspbian Jessie 所基于的版本.

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.

相反,请遵循 上给出的说明Node.js 网站:

Node.js 可从 NodeSource Debian 和 Ubuntu 二进制发行版存储库(原 Chris Lea 的 Launchpad PPA)获得.可以在 GitHub 上的 nodesource/distributions 上找到对此存储库及其脚本的支持.

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.

注意:如果您使用的是 Ubuntu Precise 或 Debian Wheezy,您可能需要阅读有关在旧发行版上运行 Node.js >= 6.x 的信息.

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

或者,对于 Node.js v7:

Alternatively, for Node.js v7:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

NodeSource 提供的 nodejs 包包含 npm.只需安装它,即可使用最新版本.

The nodejs package provided by NodeSource includes npm. Simply install that, and you'll be ready to go with the latest version.

这篇关于为什么 Debian/Ubuntu 上只能使用过时的 NPM 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆