本文将引导您完成在Ubuntu 20.04/18.04和Debian 10/9系统上安装Node.js 14的步骤。Node.js 14于2020-04-21发行,预计将于2020-10-20进入活动LTS状态,维护时段将从2021-10-19开始,并在2023-04-30达到使用寿命。

在Ubuntu 20.04/18.04和Debian 10/9上安装Node.js 14的步骤
我们将使用Node.js二进制发行版安装程序脚本在Ubuntu 20.04/18.04和Debian 10/9 Linux系统上设置Node.js 14。
步骤1:更新APT索引
在Ubuntu/Debian Linux上运行apt update命令以更新软件包存储库内容数据库:

sudo apt update

步骤2:在Ubuntu/Debian Linux上安装Node.js 14
系统更新后,首先安装所需的存储库,在Ubuntu/Debian上安装Node.js 14:

curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

上面的脚本将为NodeSource Node.js 14.x存储库创建apt源列表文件:

$ cat /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_14.x focal main
deb-src https://deb.nodesource.com/node_14.x focal main

添加存储库后,即可开始在Ubuntu/Debian Linux上安装Node.js 14:

sudo apt -y install nodejs

其他方法参考:在Debian 10系统上安装Node.js和npm的三种不同方法
步骤3:验证安装的Node.js版本
运行node -v命令:

$ node  -v

v14.0.0
注:如果您想安装最新的Node.js版本,建议您去Node.js网站下载源码包编译安装,比如下载node-v14.1.0.tar.gz包,安装出来的版本是Node.js 14.1.0。

步骤4:如果需要Node开发工具
请使用以下命令安装它们:

sudo apt -y install gcc g++ make

步骤5:要安装Yarn程序包管理器
请运行以下命令:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee 
/etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

至此,在Ubuntu 20.04/18.04和Debian 10/9上安装Node.js 14全部完成。