user1947561
user1947561

Reputation: 1197

How to use NPM modules in file run with CasperJS?

I know that CasperJS isn't usable with node directly, but can I not even use a service like cheerio, a node web scraping tool?

I tried require('cheerio'); and it said not found. So, I did:

proxies/cheerios.js

module.exports = require('cheerio');

tests/file.js

var cheerio = require('../proxies/cheerio.js');

Now, I get:

Error: Cannot find module 'util'

phantomjs://bootstrap.js:289

phantomjs://bootstrap.js:254 in require

Any suggestions? I really need to use this plugin in CasperJS, and SpookyJS isn't working...

Upvotes: 1

Views: 371

Answers (1)

RadleyMith
RadleyMith

Reputation: 1343

It's running on top PhantomJS so if you want to include external libraries you need to inject them into your code.

Upvotes: 1

Related Questions