我按照与该脚本结束了casperjs一个教程:运行phantomjs和casperjs
phantom.casperPath = "/usr/local/Cellar/casperjs/";
phantom.injectJs(phantom.casperPath + "/bin/bootstrap.js");
var utils = require('utils');
var casper = require('casper').create();
casper.start('http://www.google.com');
casper.wait(3000,function(){
this.echo(this.getTitle());
});
casper.then(function(){
casper.exit();
});
casper.run();
当我运行该脚本,我得到这个消息:
错误:无法找到模块“utils的”
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254在需要
我正在运行mac os,它的pahntomjs和casperjs都安装成功; “CasperJS版本1.1.0-beta3位于/usr/local/Cellar/casperjs/1.1-beta3/libexec,使用phantomjs版本1.9.7”
如果您不需要使用utils,脚本是否可以工作?你用什么命令来运行它? – 2014-10-06 10:57:09
我运行此命令 “phantomjs casperTest.js” 无需utils的我得到这个消息: 错误:无法找到模块 '卡斯帕' phantomjs://bootstrap.js:289个 phantomjs://bootstrap.js:254在需要 – user3017884 2014-10-06 11:49:08
因此,没有一个模块可以访问。注入引导程序之前注册到['onError'](http://phantomjs.org/api/phantom/handler/on-error.html)处理程序,以查看它是否实际上是引导程序代码的问题。 – 2014-10-06 11:53:36