通过 ppa
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
How to install Node.js 16 on Ubuntu 20.04 LTS
─➤ cat sources.list.d/nodesource.list 100 ↵
deb https://deb.nodesource.com/node_16.x focal main
deb-src https://deb.nodesource.com/node_16.x focal main
安装
好像北墙了?
─➤ sudo apt-get install -y nodejs 100 ↵
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列【新】软件包将被安装:
nodejs
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
需要下载 26.5 MB 的归档。
解压缩后会消耗 124 MB 的额外空间。
错误:1 https://deb.nodesource.com/node_16.x focal/main amd64 nodejs amd64 16.16.0-deb-1nodesource1
Could not wait for server fd - select (11: 资源暂时不可用) [IP: 23.44.51.9 443]
E: 无法下载 https://deb.nodesource.com/node_16.x/pool/main/n/nodejs/nodejs_16.16.0-deb-1nodesource1_amd64.deb Could not wait for server fd - select (11: 资源暂时不可用) [IP: 23.44.51.9 443]
E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?
找了一个教程:Nodesource 镜像使用帮助
换清华源
deb https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_16.x/ focal main
deb-src https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_16.x/ focal main
但是清华的镜像源好像已经过期了
╰─➤ sudo apt update
命中:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
命中:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
命中:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
命中:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-security InRelease
忽略:5 https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_16.x focal InRelease
错误:6 https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_16.x focal Release
404 Not Found [IP: 101.6.15.130 443]
正在读取软件包列表... 完成
E: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/nodesource/deb_16.x focal Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
咋办?
nodesource源更新了协议,似乎不允许镜像了,所以国内所有的镜像站基本都撤掉了nodesource镜像,你只能通过官方仓库的安装
nodesource的仓库没有被墙,在阿里云的服务器实测了下还有2MB/s的下载速度,你重试几次就行了