node.js - Use a node module from casperjs -



node.js - Use a node module from casperjs -

is possible install node module, installed via npm, , require casperjs script?

(i see lots of posts , tools running casper or phantom within node.js, not i'm trying do.)

the casperjs docs seem possible, show hand-written toy modules don't anything. real-world module i'm trying install imap, @ point cannot module work, built-in ones net. simple example:

class="lang-none prettyprint-override">npm install imap echo "var test = require('imap');" > test.js casperjs test.js

gives me:

class="lang-none prettyprint-override">caspererror: can't find module imap /usr/local/src/casperjs/bin/bootstrap.js:263 in patchedrequire test.js:1

(i can see imap module npm ls, , can utilize fine node.js script.)

or alternatively built-in module:

echo "var test = require('net');" > test.js casperjs test.js

complains "can't find module net"

i have npm --version of 1.4.14 , nodejs --version of v0.10.29. either of old, wonder? (casper 1.1.0-beta, , phantom 1.9.7, both of latest versions.)

phantomjs , slimerjs (the engines used casperjs) not node.js modules. can installed through npm convenience. have different base of operations infrastructure of modules distinct node.js.

you not able utilize imap or module depends on net module. fanch points out, there modules can work within phantomjs runtime.

if module uses functionality of native node.js module, seek alter implementation utilize api phantomjs provides. don't think easy though. of time run wall.

in case of imap, pretty hopeless. cannot re-implement require("net").socket, because websockets not supported in phantomjs (at to the lowest degree in 1.9.7).

node.js npm casperjs

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -