无法在 Ubuntu 上安装 nodejs 5.x

无法在 Ubuntu 上安装 nodejs 5.x

使用软件管理器会自动安装一个非常旧的版本,v0.10.25。我按照这个说明操作关联

Node.js v5.x:

NOTE: If you are using Ubuntu Precise or Debian Wheezy, you might want to read about running Node.js >= 4.x on older distros.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

当我运行第一行时,它以以下内容结尾:

Hit http://dl.google.com stable/main i386 Packages
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Fetched 821 B in 19s (41 B/s)
W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/main/source/Sources  404  Not Found

W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/dependencies/source/Sources  404  Not Found

W: Failed to fetch https://deb.nodesource.com/trusty/dists/node_5.1.0/main/source/Sources  HttpError404

W: Failed to fetch https://deb.nodesource.com/trusty/dists/node_5.1.0/main/binary-amd64/Packages  HttpError404

W: Failed to fetch https://deb.nodesource.com/trusty/dists/node_5.1.0/main/binary-i386/Packages  HttpError404

W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/dependencies/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://apt.puppetlabs.com/dists/lucid/dependencies/binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting

然后,当我运行 apt-get 命令时,我得到的是旧版本的 nodejs。我被难住了……手动安装也发生了同样的事情。我对 linux 不太了解,但还有其他方法吗?我可以从他们的网站下载正确的版本并自行安装吗?

答案1

只需从以下位置下载最新的nodejshttps://nodejs.org/en/. 使用以下方法解压并解压缩

tar xzf file.tar.gz

您可以保存存放可安装程序的文件夹(例如 /opt 或 /usr/share)。最后,链接存储在 /bin/ 的两个最重要的可执行文件“node”和“npm”,或者直接从那里运行它。

我发现这个最方便。如果您遇到任何问题请告诉我。

答案2

如果你想在开发环境中使用 Node.js,请尝试没有记录

安装和切换Node.js的多个版本非常容易。

相关内容