步骤
查看系统版本
代码语言:javascript复制lsb_release -c
Codename: bionic
备份原配置
代码语言:javascript复制sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改配置
代码语言:javascript复制sudo rm -rf /etc/apt/sources.list
sudo vi /etc/apt/sources.list
修改为
代码语言:javascript复制deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
更新软件列表
代码语言:javascript复制sudo apt-get update
安装nodejs
代码语言:javascript复制sudo apt install -y nodejs
sudo apt install -y npm
查看版本
代码语言:javascript复制sudo node -v
sudo npm -v
更新npm的包镜像源,方便快速下载
代码语言:javascript复制sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list