问题描述
使用weex-toolkit创建项目,总是卡死在phantomjs-prebuilt这个依赖上面,代理也设置了,但是就是几分钟甚至半个多小时没反应,死活不走。
问题诊断
phantomjs-prebuilt的作者这个逼写的源代码是个下载器,根本没有把phantomjs.exe上传到npm上,并且默认源是github,这样不仅下载巨慢而且默认代理根本没用。
解决方案
打开当前用户目录下的.npmrc或.yarnrc文件,末尾添加一行。以下两个应该是一样的,选一个就可以。(第二个是笔者fork的仓库)
# .npmrc
PHANTOMJS_CDNURL=https://gitee.com/lyliyuan633/phantomjs/blob/master/
# .yarnrc
PHANTOMJS_CDNURL "https://gitee.com/lyliyuan633/phantomjs/blob/master/"
或者
# .npmrc
PHANTOMJS_CDNURL=https://gitee.com/finntenzor/phantomjs/blob/master/
# .yarnrc
PHANTOMJS_CDNURL "https://gitee.com/finntenzor/phantomjs/blob/master/"
加速原理和其他说明
今天用weex创建项目,慢的要死,发现总是卡在phantomjs-pr