nvm切换node.js的国内镜像源

npm是node.js的包管理工具,经常会使用npm安装node.js的一些modules。但是npm的默认下载源是国外站点,这就导致了下载的速度非常感人。所以,我们同常会把下载源站点设置成国内镜像,提高modules的下载速度。
首先安装nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

在环境变量中

cd
vim .bash_profile

添加下面两行语句

export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
source ~/.nvm/nvm.sh

是环境变量生效

source .bash_profile

查看当前镜像源

npm config get registry

淘宝源,使用最新版,旧版停止了

npm config set registry https://registry.npmmirror.com

重置官方源

npm config set registry https://registry.npmjs.org/
点赞

发表回复