Using yarn to install electron and chromedriver in China is often the problem of inability to connect. At this time, rather than setting up a proxy, we may prefer to use a domestic mirror repository to speed up the process. And when installing electron, it is useless to just set the global proxy of yarn. So how to set the proxy according to different packages? You can set it up by following the sample commands provided in the list below.
yarn global settings
Sets the repository address used by yarn to install general packages.
yarn config set registry https://r.npm.taobao.org Register the module image yarn config set disturl https://npm.taobao.org/dist # node-gyp compile dependent node source image
Here is the result of running the above command, you can clearly see if the setup was successful or not.
yarn install specific package settings
Set the repository address used by yarn to install packages such as electron and chromedriver. You can choose one or two commands to set according to your needs, and it is necessary to add all of them.
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass binary package mirror yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron binary package mirror yarn config set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer binary package mirror yarn config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver binary package mirror yarn config set operadriver_cdnurl https://npm .taobao.org/mirrors/operadriver # operadriver binary package mirror yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs binary package mirror yarn config set selenium_cdnurl https://npm.taobao.org/mirrors /selenium # selenium binary package mirror yarn config set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector # node-inspector binary package mirror
Similar to the above, after running the command you can clearly see if the setup was successful or not.