在编译或打包 nodejs 开发的项目时,需要去 github 上去拉取一些源代码或二进制代码时, 非常的慢, 甚至会导致打包或编译不成功;其实可以通过设置合适的镜像来解决该问题; 首先推荐采用华为的镜像;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #!/usr/bin/env zsh
yarn config set registry https://mirrors.huaweicloud.com/repository/npm/ yarn config set disturl https://mirrors.huaweicloud.com/nodejs yarn config set sass_binary_site https://mirrors.huaweicloud.com/node-sass yarn config set phantomjs_cdnurl https://mirrors.huaweicloud.com/phantomjs yarn config set chromedriver_cdnurl https://mirrors.huaweicloud.com/chromedriver yarn config set operadriver_cdnurl https://mirrors.huaweicloud.com/operadriver
yarn config set electron_mirror https://mirrors.huaweicloud.com/electron/ yarn config set python_mirror https://mirrors.huaweicloud.com/python
yarn config set electron_builder_binaries_mirror https://mirrors.huaweicloud.com/electron-builder-binaries/
|
将上面的代码存到 setupYarn.zsh 中;
1 2
| chmod +x setupYarn.zsh ./setupYarn.zsh
|
通过上面的操作基本都能解决问题, 不过也有可能镜像中有部分文件不存在, 这可以尝试以下其他镜像, 比如淘宝、清华