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

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

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

在环境变量中

  1. cd
  2. vim .bash_profile

添加下面两行语句

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

是环境变量生效

  1. source .bash_profile

查看当前镜像源

  1. npm config get registry

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

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

重置官方源

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