淘宝镜像源的域名已由之前的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
| yarn config set registry https://registry.npmmirror.com yarn config set disturl https://npmmirror.com/mirrors/node yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass yarn config set puppeteer_download_host https://npmmirror.com/mirrors yarn config set chromedriver_cdnurl https://npmmirror.com/mirrors/chromedriver yarn config set operadriver_cdnurl https://npmmirror.com/mirrors/operadriver yarn config set phantomjs_cdnurl https://npmmirror.com/mirrors/phantomjs yarn config set selenium_cdnurl https://npmmirror.com/mirrors/selenium yarn config set node_inspector_cdnurl https://npmmirror.com/mirrors/node-inspector yarn config set sentrycli_cdnurl https://npmmirror.com/mirrors/sentry-cli yarn config set electron_mirror https://npmmirror.com/mirrors/electron/ yarn cache clean
|
临时修改源:
1
| yarn save 软件名 --registry https://registry.npmmirror.com/
|
如需还原到默认源,将上述命令中的 npmmirror.com 替换为 yarnpkg.com。
2. NPM 设置
全局设置:
1 2 3 4
| npm set registry https://registry.npmmirror.com
npm cache clean --force
|
如需还原到默认源,将上述命令中的 npmmirror.com 替换为 npmjs.org。
NPM v8版本之前支持的一些配置参数,如electron_mirror、disturl等,在v9及后面的版本都不再支持,可以在 https://docs.npmjs.com/cli/v11/using-npm/config#config-settings 页面查看npm支持的所有配置参数。
其他常用命令:
1 2 3 4 5 6 7 8
| npm get registry
npm config list
npm help config
|