Skip to content

Instantly share code, notes, and snippets.

@liviaerxin
Last active August 15, 2021 14:15
Show Gist options
  • Save liviaerxin/e169c4b92f22697af6f70c8d44d34ad3 to your computer and use it in GitHub Desktop.
Save liviaerxin/e169c4b92f22697af6f70c8d44d34ad3 to your computer and use it in GitHub Desktop.
npm mirror setting #npm

npm and yarn mirror

mirror priority:

Project .npmrc > Global .npmrc > Default mirror source Project .yarnrc > Global .yarnrc > Default mirror source

npm mirror

  1. Restore to default repository

    npm config delete registry
    #or
    npm config set registry https://registry.npmjs.org/
  2. Get current mirror

    npm config get registry
  3. Set mirror

    npm config set registry http://registry.npm.taobao.org/
    
    #other mirrors
    npm config set disturl https://npm.taobao.org/dist 
    npm config set electron_mirror https://npm.taobao.org/mirrors/electron/ 
    npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ 
    npm config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/

    Or Edit ~/.npmrc file to set.

    registry=https://registry.npm.taobao.org
    sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
    phantomjs_cdnurl=http://cnpmjs.org/downloads
    electron_mirror=https://npm.taobao.org/mirrors/electron/
    sqlite3_binary_host_mirror=https://foxgis.oss-cn-shanghai.aliyuncs.com/
    profiler_binary_host_mirror=https://npm.taobao.org/mirrors/node-inspector/
    chromedriver_cdnurl=https://cdn.npm.taobao.org/dist/chromedriver

yarn mirror

  1. Restore to default repository

    yarn config delete registry
    #or
    yarn config set registry https://registry.yarnpkg.com
  2. Get current mirror

    yarn config get registry
  3. Set mirror

    yarn config set registry http://registry.npm.taobao.org/
    #other mirrors
    yarn config set disturl https://npm.taobao.org/dist -g 
    yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ -g 
    yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g 
    yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g

    Or Edit ~/.yarnrc file to set.

    registry "https://registry.npm.taobao.org"
    sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
    phantomjs_cdnurl "http://cnpmjs.org/downloads"
    electron_mirror "https://npm.taobao.org/mirrors/electron/"
    sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
    profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
    chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment