在 Ubuntu 16.04 服务器上安装 NodeJS 4.4.7 或更高版本

Installing NodeJS 4.4.7 or later on Ubuntu 16.04 server

为了 运行 使用最新版本的 Meteor 创建的 Meteor 应用程序,我需要在 Ubuntu 16.04 服务器上安装 Node.js 4.4.7 或更高版本。我完全按照 DigitalOcean tutorial 中的说明操作:

cd ~
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh

然而,当我执行脚本时,在一些似乎无误终止的 Get 和 Ign 进程之后,我得到一个 404 Not Found 错误,然后通知 Error executing command, exiting:

...
Ign:13 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main Translation-en
Err:7 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main amd64 Packages
  404  Not Found
Ign:9 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main i386 Packages
Ign:11 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main all Packages
Ign:12 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main Translation-en_GB
Ign:13 http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial/main Translation-en
Fetched 190 kB in 2s (74.5 kB/s)
Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/chris-lea/node.js/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/chris-lea/node.js/ubuntu/dists/xenial/main/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting

我已经能够使用 sudo apt-get install nodejs 安装 NodeJS 4.2.6,但我无法更新到较新的版本。我错过了什么?

我发现以下步骤可以解决这个问题:

sudo apt-get update
sudo apt-get install build-essential libssl-dev curl
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash

关闭并重新打开终端会话

source ~/.profile
nvm ls-remote
nvm install v4.4.7
nvm use v4.4.7
node -v

显示:

v4.4.7

来源:Installing using Node Version Manager (NVM)

注意:curl <url> | bash需要信任下载脚本的提供者。