我已经下载了最新版本的casperjs (1.03)和phantomjs (1.9.2)。
所以我从casper页面获取了这个简单的小脚本:
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
var casper = new require('casper').Casper();当我尝试运行它时,我得到了以下错误:
noname:phantomjs-1.9.2 Tom$ casperjs/bin/casperjs tipico2.js
Fatal: [Errno 2] No such file or directory; did you install phantomjs?所以,这是我的目录结构:
phantomjs-1.9.2/ <-- the folder containing phantomjs
phantomjs-1.9.2/casperjs/ <-- a subfolder containting casperjs为什么它不起作用?
发布于 2013-10-20 20:06:12
解决方案实际上非常简单。只要导出phantomjs的二进制文件所在的路径即可。在我的例子中,这是/Users/Tom/Downloads/phantomjs-1.9.2/bin,因此
export PATH=$PATH:/Users/Tom/Downloads/phantomjs-1.9.2/bin发布于 2015-07-02 01:42:02
在osx上全局安装带有npm的casper时,遇到了同样的问题。首先,我使用以下命令将环境变量phantomjs设置为phantomjs的安装路径(通常为/usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs PHANTOMJS_EXECUTABLE
export PHANTOMJS_EXECUTABLE=/usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs phantomjs这只在一定程度上有所帮助,因为我仍然得到一个错误,比如没有文件和文件夹/usr/local/bin/phantomjs,所以我刚刚创建了symlink,并使用以下命令将其指向real binary文件夹
ln -s /usr/local/lib/node_modules/casperjs/node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/local/bin/phantomjs希望这能对某些人有所帮助:)
发布于 2016-03-14 21:52:24
对于OS X:
brew install casperjs --devel
brew install phantomjs
它会工作的
https://stackoverflow.com/questions/19476947
复制相似问题