淘宝镜像源的域名已由之前的npm.taobao.org变更为npmmirror.com,见阿里云公告。 目前老域名(npm.taobao.org)的证书已过期,若继续使用老域名会出现certificate has expired的错误提示。
1. Yarn 设置
查看当前使用的镜像源:
1
yarn config get registry
全局修改:
1 2 3 4 5 6 7 8
yarn config set registry https://registry.npmmirror.com -g yarn config set disturl https://npmmirror.com/dist -g yarn config set electron_mirror https://npmmirror.com/mirrors/electron/ -g yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass/ -g yarn config set phantomjs_cdnurl https://npmmirror.com/mirrors/phantomjs/ -g yarn config set chromedriver_cdnurl https://cdn.npmmirror.com/dist/chromedriver -g yarn config set operadriver_cdnurl https://cdn.npmmirror.com/dist/operadriver -g yarn config set fse_binary_host_mirror https://npmmirror.com/mirrors/fsevents -g
临时修改:
1
yarn save 软件名 --registry https://registry.npmmirror.com/
2. NPM 设置
查看当前使用的镜像源:
1
npm get registry
全局设置:
1 2 3 4 5
npm config set registry https://registry.npmmirror.com npm config set disturl https://npmmirror.com/dist npm config set electron_mirror https://npmmirror.com/mirrors/electron/ npm config set sass_binary_site https://npmmirror.com/mirrors/node-sass/ npm config set phantomjs_cdnurl https://npmmirror.com/mirrors/phantomjs/
npm v9 版本会报错:ELECTRON_MIRROR is not a valid npm option。 需要切换为 npm v8 版本:npm install -g npm@^8