0

当我尝试在新的 Ubuntu Server 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

请帮忙。

4

3 回答 3

0

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

于 2017-07-20T07:31:26.987 回答
0

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

于 2017-07-04T18:46:01.647 回答
0

答案隐藏在这个线程中:在 Ubuntu Trusty 上安装 NodeJS

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

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

然后从同一个目录:

sudo bash ./setup_6.x

最后:

sudo apt-get install nodejs

哪个做到了。

于 2017-07-04T19:04:56.603 回答