如何在使用CasperJS的文件中使用NPM模块?
我知道CasperJS不直接与节点一起使用,但是我甚至不能使用像cheerio
这样的服务,一个节点的网页抓取工具吗?
我尝试require('cheerio');
它说没有find。 所以我做了:
代理/ cheerios.js
module.exports = require('cheerio');
testing/ file.js
var cheerio = require('../proxies/cheerio.js');
现在,我得到:
错误:找不到模块'util'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254中的require
有什么build议么? 我真的需要在CasperJS中使用这个插件,而SpookyJS不工作…
它运行在顶部PhantomJS上,所以如果你想包含外部库,你需要将它们注入到代码中。