Use a node module from casperjs

PhantomJS and SlimerJS (the engines that are used for CasperJS) are not Node.js modules. They can be installed through npm for convenience. They have a different base infrastructure of modules which is distinct from Node.js.

You will not be able to use imap or any module that depends on the net module. As Fanch points out, there are modules that can work inside the phantomjs runtime.

If a module only uses some functionality of some native node.js module, you could try to change the implementation to use the API that phantomjs provides. I don’t think this is easy though. Most of the time you will run into a wall.

In the case of imap, it is pretty hopeless. You cannot even re-implement the require("net").Socket, because WebSockets are not supported in phantomjs (at least in 1.9.7).

Leave a Comment