[记录]安装 PhantomJS 报 PhantomJS not found on PATH 错误

已经设置了 yarn 的镜像源为淘宝镜像,也在 .npmrc 中设置了 phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/,但执行 yarn install 时还是无法正确安装 PhantomJS,错误代码如下:

...
[-/2] ⠂ waiting...
[2/2] ⠂ phantomjs-prebuilt: Receiving...
[-/2] ⠂ waiting...
[-/2] ⠂ waiting...
error /home/charley/CODES/charley-praise/node_modules/phantomjs-prebuilt: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /home/charley/CODES/charley-praise/node_modules/phantomjs-prebuilt
Output:
PhantomJS not found on PATH
Downloading https://npm.taobao.org/mirrors/phantomjs//phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...

Error making request.
Error: tunneling socket could not be established, cause=connect EINVAL 0.0.31.182:80 - Local (0.0.0.0:0)
    at ClientRequest.onError (/home/charley/CODES/charley-praise/node_modules/tunnel-agent/index.js:177:17)
    at ClientRequest.g (events.js:292:16)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1281:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)

解决方案也很简单,根据错误提示,手动到 https://npm.taobao.org/mirrors/phantomjs//phantomjs-2.1.1-linux-x86_64.tar.bz2 下载 PhantomJS 文件,并将该文件拷贝到 /tmp/phantomjs 目录下:

 cp phantomjs-2.1.1-linux-x86_64.tar.bz2 /tmp/phantomjs 

完。

你可能感兴趣的:([记录]安装 PhantomJS 报 PhantomJS not found on PATH 错误)