[英]Installing NodeJS on Ubuntu 16.04 Server with the Package manager installs only the distro version (v.4) instead of LTS
I have this odd problem that when I try to install NodeJS on a fresh Ubuntu Server VM. 我有一个奇怪的问题,当我尝试在新的Ubuntu Server VM上安装NodeJS时。
I execute the two simple steps from the official instruction but somehow I manage to fail. 我按照官方指示执行了两个简单的步骤,但是以某种方式我失败了。
In the home directory of my user I execute curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
在我的用户的主目录中,执行
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
which ends successfully and then sudo apt-get install -y nodejs
but this results in the installation of v.4.2.6. 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。
Output can be seen below: 输出如下所示:
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
Please help. 请帮忙。
You probably have to run sudo apt-get update
before sudo apt-get install
to update the local package lists after adding the sources for 6.x. 在添加6.x的源代码之后,您可能必须在
sudo apt-get install
之前运行sudo apt-get update
来更新本地软件包列表。 If you do that, you should see version 6 being installed. 如果这样做,则应该看到正在安装版本6。
The answer was hiding in this thread: Installing NodeJS on Ubuntu Trusty 答案就隐藏在此线程中: 在Ubuntu Trusty上安装NodeJS
So it must have been some kind of an issue with curl using the local network so I used wget to download like this: 因此,使用本地网络一定是curl的问题,所以我使用wget这样下载:
wget https://deb.nodesource.com/setup_6.x
And then from the same directory: 然后从同一目录:
sudo bash ./setup_6.x
And finally: 最后:
sudo apt-get install nodejs
Which did it. 做到了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.