淘宝镜像源的域名已由之前的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 9 10 11 12 13 14 15
yarn config set registry https://registry.npmmirror.com yarn config set disturl https://npmmirror.com/mirrors/node
yarn config set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass yarn config set electron_mirror https://registry.npmmirror.com/mirrors/electron/ yarn config set puppeteer_download_host https://registry.npmmirror.com/mirrors yarn config set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver yarn config set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver yarn config set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs yarn config set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium yarn config set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector yarn config set sentrycli_cdnurl https://registry.npmmirror.com/mirrors/sentry-cli
yarn cache clean
临时修改源:
1
yarn save 软件名 --registry https://registry.npmmirror.com/
2. NPM 设置
查看当前使用的镜像源:
1
npm get registry
全局设置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
npm set registry https://registry.npmmirror.com npm set disturl https://npmmirror.com/mirrors/node
npm set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass npm set puppeteer_download_host https://registry.npmmirror.com/mirrors npm set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver npm set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver npm set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs npm set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium npm set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector npm set sentrycli_cdnurl https://registry.npmmirror.com/mirrors/sentry-cli
npm cache clean --force
npm v9 版本会报错:ELECTRON_MIRROR is not a valid npm option。 需要切换为 npm v8 版本:npm install -g npm@^8