繁体   English   中英

使用软件包管理器在Ubuntu 16.04 Server上安装NodeJS只会安装发行版(v.4)而不是LTS

[英]Installing NodeJS on Ubuntu 16.04 Server with the Package manager installs only the distro version (v.4) instead of LTS

我有一个奇怪的问题,当我尝试在新的Ubuntu Server VM上安装NodeJS时。

我按照官方指示执行了两个简单的步骤,但是以某种方式我失败了。

在我的用户的主目录中,执行curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs成功结束,然后sudo apt-get install -y nodejs但这导致安装v.4.2.6。

输出如下所示:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3161 kB of archives.
After this operation, 13,2 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 97187 files and directories currently installed.)
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4.1_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4.1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

请帮忙。

在添加6.x的源代码之后,您可能必须在sudo apt-get install之前运行sudo apt-get update来更新本地软件包列表。 如果这样做,则应该看到正在安装版本6。

答案就隐藏在此线程中: 在Ubuntu Trusty上安装NodeJS

因此,使用本地网络一定是curl的问题,所以我使用wget这样下载:

wget https://deb.nodesource.com/setup_6.x

然后从同一目录:

sudo bash ./setup_6.x

最后:

sudo apt-get install nodejs

做到了。

您可能会考虑使用nvm而不是发行版软件包来安装Node。 这为您提供了更大的灵活性来管理您的Node版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM