包管理器换源
NPM换源
npm install --registry=https://registry.npmmirror.com # 临时指定
npm config set registry https://registry.npmmirror.com # 更改配置
npm config set registry https://registry.npmjs.org/ # 地址还原
YARN 换源
yarn add [package_name] --registry https://registry.npmmirror.com/ #临时修改
yarn config set registry https://registry.npmjs.org/ #更改配置
yarn config set registry https://registry.yarnpkg.com #地址还原
PNPM
pnpm install --registry=https://registry.npmmirror.com # 临时指定
pnpm config set registry https://registry.npmmirror.com # 更改配置
pnpm config set registry https://registry.npmjs.org/ # 地址还原
设置常用NPM包的国内镜像
npm install phantomjs --phantomjs_cdnurl=http://npm.taobao.org/mirrors/phantomjs
npm install chromedriver --chromedriver_cdnurl=http://npm.taobao.org/mirrors/chromedriver
npm install operadriver --operadriver_cdnurl=http://npm.taobao.org/mirrors/operadriver
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/
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
yarn config set chromedriver_cdnurl https://cdn.npm.taobao.org/dist/chromedriver -g
yarn config set operadriver_cdnurl https://cdn.npm.taobao.org/dist/operadriver -g
yarn config set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents -g
快捷方式
# 使用yrm或nrm管理镜像地址
npm install -g nrm --registry=https://registry.npmmirror.com
npm install -g yrm --registry=https://registry.npmmirror.com
nrm ls # tym ls
nrm use taobao # yrm use taobao