Ubuntu自带的Nodejs版本过低,因此我选择基于NodeSource软件源安装较高版本的Nodejs。
NodeSource (https://github.com/nodesource/distributions)是一个公司,聚焦于提供企业级的 Node 支持。它维护了一个 APT 软件源,其中包含了很多 Node.js 版本。
1. 安装Node.js V16版本
Ubuntu:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
Debian:
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
apt-get install -y nodejs
2. 安装Node.js V18版本
Ubuntu:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
Debian:
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - &&\
apt-get install -y nodejs