I realize "Running PhantomJS on Heroku" is a related but slightly different question as I am trying to use a node app.
I'm having trouble deploying a casperJS (based on phantomJS) script for a node app. I've tried deploying to Heroku by placing the PhantomJS 64-bit binary in my app's /bin
directory, but I get the following error when I try to run PhantomJS:
phantomjs: error while loading shared libraries: libQtWebKit.so.4: cannot open shared object file: No such file or directory
From what I've read this can be solved by installing the QtWebKit library, but Heroku does not have this installed. Is there another hosting provider I could use that will work or a way to install this package on Heroku?
Relevant code:
app.get('/', function(request, response) {
var sys = require('sys')
var exec = require('child_process').exec;
var child;
//works but gives error while loading shared library libqtwebkit.so.4
child = exec("phantomjs --version | tr -d '\n'", function(error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr + '\n');
response.header('Content-Type', 'application/json');
response.send('_testcb(stdout:' + stdout + '\nstderr:' + stderr + ')', 200);
if(error !== null) {
console.log('exec error: ' + error);
}
});
});
I've signed up for beta-testing on Nodester but their documentation is still pretty limited at this point.
EDIT: I was able to get it working by simply copying the lib folder of PhantomJS to the root directory of my node app.
Copy the lib folder of phantomjs to the root directory of your node app You could also try putting a sym link in bin or sbin The key is that is has to run from terminal using the same account that node runs on. Also, node-phantom is a good npm library to utilize phantomjs, once you get it working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With