Solve the problem of timeout and slow installation of yarn packages such as electron and chromedriver

Installing electron and chromedriver with yarn in China is often a problem that cannot be connected. At this time, we may prefer to use a mirror repository in China to speed up the process, rather than setting up a proxy. And when installing electron, it is useless to set yarn’s global proxy alone. So how do you set up proxies based on different packages? You can follow the sample commands provided in the list below to set it up.


yarn installation

yarn global settings

Set the repository address used by yarn to install general packages.

yarn config set registry 注册模块镜像
yarn config set disturl # node-gyp 编译依赖的 node 源码镜像

This is the result of running the above command, and you can clearly see if the setup was successful.

yarn install specific package settings

Set the address of the repository used by yarn to install packages such as electron and chromedriver. You can choose one or two commands to set them up as needed, it is not necessary to add them all.

yarn config set sass_binary_site # node-sass 二进制包镜像
yarn config set electron_mirror # electron 二进制包镜像
yarn config set puppeteer_download_host # puppeteer 二进制包镜像
yarn config set chromedriver_cdnurl # chromedriver 二进制包镜像
yarn config set operadriver_cdnurl # operadriver 二进制包镜像
yarn config set phantomjs_cdnurl # phantomjs 二进制包镜像
yarn config set selenium_cdnurl # selenium 二进制包镜像
yarn config set node_inspector_cdnurl # node-inspector 二进制包镜像

Similar to the above, you can clearly see if the setup was successful after running the command.