淘宝源

淘宝 npm 地址: http://npm.taobao.org/

  1. npm 临时使用

    # 以 events 依赖包为例
    npm --registry <https://registry.npmmirror.com> install events --save
    
    
  2. npm 持久使用

    npm config set registry <https://registry.npmmirror.com>
    
    # 验证:通过以下方式验证结果
    npm config get registry
    
    # 使用:以 events 依赖包为例
    npm install events --save
    
    
  3. cnpm 使用

    npm install -g cnpm --registry=https://registry.npmmirror.com
    
    # 使用:以 events 依赖包为例
    cnpm install events --save
    
    

还原 npm 仓库地址:

npm config set registry <https://registry.npmjs.org/>

yarn

查看当前地址

yarn config get registry

修改源地址为淘宝 NPM 镜像

yarn config set registry <https://registry.npmmirror.com/>

修改源地址为官方源

yarn config set registry <https://registry.yarnpkg.com>