安装淘宝镜像cnpm

npm使用国内淘宝镜像

一、通过命令配置

  1. 设置淘宝镜像源
npm config set registry https://registry.npm.taobao.org/
  1. 设置官方镜像源
npm config set registry https://registry.npmjs.org
  1. 查看镜像使用状态
npm config get registry

二、安装cnpm

  1. 安装cnpm
 npm install -g cnpm --registry=https://registry.npm.taobao.org
  1. 安装过程中安装失败
    在这里插入图片描述
    解决方案:
// 1.清除缓存
npm cache clean --force
// 2.切换新源
npm config set registry https://registry.npmmirror.com
// 3. 查看源是否设置成功
npm config get registry
// 4. 安装
到这里就可以正常使用npm命令安装需要的工具了。如( npm install -g cnpm )
  1. 查看cnvm
cnpm -v
  1. 注册模块镜像
 # 注册模块镜像npm set registry https://registry.npm.taobao.org  // node-gyp 编译依赖的 node 源码镜像  npm set disturl https://npm.taobao.org/dist // 清空缓存  npm cache clean --force  // 安装cnpm  npm install -g cnpm --registry=https://registry.npm.taobao.org