sudo apt update
sudo apt install npm
sudo npm install -g n
//创建下载目录并授权
sudo mkdir -p /usr/local/n sudo chown -R $(whoami) /usr/local/n
//创建安装目录并授权
sudo mkdir -p /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
#阿里云镜像源
echo 'export N_NODE_MIRROR=https://npmmirror.com/mirrors/node' >> ~/.bashrc
#腾讯云镜像源
echo 'export N_NODE_MIRROR=https://mirrors.cloud.tencent.com/nodejs-release/' >> ~/.bashrc
#中国科学技术大学镜像源
echo 'export N_NODE_MIRROR=https://mirrors.ustc.edu.cn/node/' >> ~/.bashrc
#npm仓库阿里云源
npm config set registry=https://registry.npmmirror.com
#npm仓库腾讯云源
npm config set registry=http://mirrors.cloud.tencent.com/npm/
#npm仓库华为云源
npm config set registry=https://mirrors.huaweicloud.com/repository/npm/
标签:node,npm,mirrors,sudo,更新,usr,https,local
From: https://www.cnblogs.com/hongdoudou/p/16942006.html