Open
Description
今天安装包时碰到问题:
> phantomjs-prebuilt@2.1.14 install /Users/will/work/my-project/node_modules/phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
Saving to /var/folders/mh/2ptfthxj2qb49jscj1b0gjsm0000gn/T/phantomjs/phantomjs-2.1.1-macosx.zip
Receiving...
Error making request.
Error: connect ETIMEDOUT 54.231.113.227:443
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
后来发现是天朝网络的原因:它的安装过程中要去 github 下载一个包,而 github release 文件放在亚马逊 aws 上(被墙了)。解决方法是借助淘宝镜像 (http://cnpmjs.org/downloads https://npm.taobao.org/mirrors/phantomjs/) 安装,输入以下命令:
PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs npm install phantomjs-prebuilt
phantomjs
已改名为phantomjs-prebuilt
https://github.com/Medium/phantomjs#versioning
同样安装 node-sass
也会出现类似的问题,解决方法依然是淘宝镜像:
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass npm install node-sass
Tips:
如果不想每次都输入前面变量可以将它们写入 ~/.npmrc
文件中😄(https://docs.npmjs.com/files/npmrc)
sass_binary_site = https://npm.taobao.org/mirrors/node-sass
phantomjs_cdnurl = https://npm.taobao.org/mirrors/phantomjs
registry = https://registry.npm.taobao.org