我遵循了一个关于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 in require
运行mac的Im及其pahntomjs和casperjs都已成功安装;"CasperJS version 1.1.0-beta3 at /usr/local/Cellar/casperjs/1.1-beta3/libexec,using phantomjs version 1.9.7“
发布于 2015-03-27 22:53:10
你安装了phantomjs的所有前置要求了吗?
Packages CentOS:
gcc gcc-c++ make flex bison gperf ruby \
openssl-devel freetype-devel fontconfig-devel libicu-devel sqlite-devel \
libpng-devel libjpeg-develUbuntu包:
build-essential g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev第二
为什么需要注入引导程序?Phantomjs在运行时总是使用bootstrap.js,所以您可以删除它,除非您在此文件中做了一些更改。
发布于 2014-10-06 22:06:50
您应该删除phantom.casperPath末尾的/。
https://stackoverflow.com/questions/26214631
复制相似问题