npm使用国内镜像源

[toc]

一、通过配置 npm

  • 通过 config 设置

npm config set registry https://registry.npm.taobao.org

# 验证指令
npm config get registry
  • 命令行指定
npm --registry https://registry.npm.taobao.org
  • 编辑配置文件 ~/.npmrc 加入下面内容
registry = https://registry.npm.taobao.org

二、通过使用 cnpm


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

# 使用 cnpm 
cnpm install xxx

三、相关资料

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

猜你喜欢

转载自blog.51cto.com/tchuairen/2427979
今日推荐