npm镜像源

概述

经常使用镜像源

  1. 官方镜像源 https://registry.npmjs.org
  2. 淘宝镜像源 https://registry.npm.taobao.org

查看镜像源

// 查看当前镜像源
npm config get registry

设置镜像源

npm

  1. 临时修改
npm install package_name --registry https://registry.npm.taobao.org
  1. 永久修改
npm config set registry https://registry.npm.taobao.org

cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

全局安装cnpm,使用cnpm安装node

nrm管理

// 全局安装 nrm
npm install -g nrm --registry=https://registry.npm.taobao.org
// 查看能够使用的镜像列表
nrm ls 
// 使用淘宝镜像源
nrm use taobao

.npmrc文件

编辑.npmrc指定全局镜像源或局部镜像源npm

// 全局镜像源
registry =https://registry.npm.taobao.org

// 局部镜像源
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
评论 ( 0 )