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

时间:2017-07-04 18:39:33

标签: node.js installation ubuntu-server package-management

当我尝试在新的Ubuntu服务器VM上安装NodeJS时,我遇到了一个奇怪的问题。

我从官方指令中执行了两个简单的步骤,但不知怎的,我设法失败了。

在我的用户的主目录中,我执行curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -,然后成功结束,然后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

请帮忙。

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

答案隐藏在这个帖子中:Installing NodeJS on Ubuntu Trusty

所以使用本地网络卷曲一定是个问题,所以我用wget下载这样:

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

然后从同一目录:

sudo bash ./setup_6.x

最后:

sudo apt-get install nodejs

是做了什么。

答案 2 :(得分:0)

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