nodejs安装

  1. 以 sudo 用户身份运行下面的命令,下载并执行 NodeSource 安装脚本:

curl -sL http<font style="color:rgb(152, 104, 1);">s:</font>//<font style="color:rgb(166, 38, 164);">deb</font>.nodesource.<font style="color:rgb(166, 38, 164);">com</font>/setup_16.<font style="color:rgb(166, 38, 164);">x</font> | sudo -E bash -

这个脚本将会添加 NodeSource 的签名 key 到你的系统,创建一个 apt 源文件,安装必备的软件包,并且刷新 apt 缓存。 如果你需要另外的 Node.js 版本,例如16.x,将setup_14.x修改为setup_16.x

ls /var/lib/apt/lists |grep nodesource# 检查源

nodejs%26yarn - 图1

apt-cache madison package nodejs # 查看版本

nodejs%26yarn - 图2

  1. apt install nodejs && node --verison && npm --version
    nodejs%26yarn - 图3

yarn安装

npm install -g npm # 升级下Npm

npm install -g yarn # 安装yarn