💿 npm 换源 (转载)

个人感觉使用第三种比较方便

本文转载自: 设置npm的registry

一 原npm地址

npm config set registry http://registry.npmjs.org

二 设置国内镜像

  1. 通过config命令
npm config set registry http://registry.npm.taobao.org 
npm info underscore (如果上面配置正确这个命令会有字符串response)
  1. 命令行指定
npm --registry http://registry.npm.taobao.org info underscore
  1. 编辑 ~/.npmrc 加入下面内容
registry = http://registry.npm.taobao.org

三 使用 nrm 管理 registry 地址

  1. 下载nrm
npm install -g nrm --registry=https://registry.npm.taobao.org
  1. 添加registry地址
nrm add npm http://registry.npmjs.org
nrm add taobao http://registry.npm.taobao.org
  1. 切换npm registry地址
nrm use taobao
nrm use npm

四 其他

搜索镜像: https://npm.taobao.org 建立或使用镜像,参考: https://github.com/cnpm/cnpmjs.org

原文地址:https://www.cnblogs.com/CodeAndMoe/p/13360029.html