casperjs找不到phantomjs [英] casperjs does not find phantomjs

查看:74
本文介绍了casperjs找不到phantomjs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了最新版本的casperjs(1.03)和phantomjs(1.9.2).

I've downloaded the latest version of casperjs (1.03) and phantomjs (1.9.2).

所以我从casper页面上提取了这个简单的脚本:

So I took this little simple script from the casper page:

var casper = require('casper').create({
    verbose: true,
    logLevel: "debug"
});
var casper = new require('casper').Casper();

当我尝试运行它时,出现以下错误:

and when I try to run it I get the following error:

noname:phantomjs-1.9.2 Tom$ casperjs/bin/casperjs tipico2.js 
Fatal: [Errno 2] No such file or directory; did you install phantomjs?

所以,这是我的目录结构:

So, this is my directory structure:

phantomjs-1.9.2/ <-- the folder containing phantomjs
phantomjs-1.9.2/casperjs/ <-- a subfolder containting casperjs

为什么不起作用?

推荐答案

解决方案实际上非常简单.只需导出phantomjs二进制文件所在的路径即可.在我的情况下,这是/Users/Tom/Downloads/phantomjs-1.9.2/bin,因此

The solution is actually very simple. Just export the path where the binary of phantomjs is. In my case this is /Users/Tom/Downloads/phantomjs-1.9.2/bin, hence

export PATH=$PATH:/Users/Tom/Downloads/phantomjs-1.9.2/bin

这篇关于casperjs找不到phantomjs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆