How to Run Phantomjs on Heroku

How to run Node controlled Phantomjs/Casperjs script in Heroku

The issue actually had nothing to do with Heroku. As noted in this SO answer, using exec and providing any environmental variables in the options parameter replaces the entire set of environment variables. This includes the path, effectively overwriting any paths already specified to Heroku in the buildpack and npm modules.

You can create a copy of process.env and pass that along in the parameters in addition to other environmental parameters needed to be passed.

Run a phantom.js file on Heroku regularly

Found it: I only had to write

phantomjs phantom.js

in order to get it working. It was the "run" that made the expression invalid

How to use PhantomJS 2.5.0 Beta on Heroku

Ultimately, I was able to figure it out! There are a few things that you have to do...

TL;DR:

  1. heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
  2. heroku buildpacks:add https://github.com/lookitsatravis/heroku-buildpack-phantomjs.git
  3. cat > Aptfile << EOL
    webp
    libhyphen0
    https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.1-8ubuntu1_amd64.deb
    https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb
    EOL
  4. Commit Aptfile, push to Heroku app.

More info

  1. Dependencies: You have to use the Heroku Apt buildpack to install the missing dependencies. First, you need to add the buildpack to your app:

    heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

    Next, you'll create a file in your project root called Aptfile. Here's where we add the missing dependencies for PhantomJS 2.5.0 Beta. 2.5.0 introduces webp support, so we need that. libhyphen0 is required as well, though I'm not sure how it us used. Finally, we use gcc-5 and the latest libstdc++6. Contents should look like this:

webp
libhyphen0
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.1-8ubuntu1_amd64.deb
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb

  1. PhantomJS: Next we grab the latest version of PhantomJS. I've created a fork of the most popular PhantomJS buildpack and updated it for use with 2.5.0 beta. 2.5.0 beta has builds for trusty as well as xenial, so the build pack will detect the Heroku stack and use the appropriate one (though the cedar-16 stack is still in beta at the time of this post). So, add it to your app:

    heroku buildpacks:add https://github.com/lookitsatravis/heroku-buildpack-phantomjs.git

  2. Deploy: All that's left is deployment! Commit the Aptfile to your repo, make sure the build packs are setup, and then push to Heroku.

Took a bit of trial and error, but ultimately I was able to get it up and running. Hope this helps others until the final candidate is released.

Deploy phantomJS to node.js 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.

Is there a working nodejs/phantomjs Heroku buildpack?

Heroku Toolbelt now has first class support for multiple buildpacks, so you can get a working Node and PhantomJS setup with the following:

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs.git

heroku buildpacks:add --index 1 https://github.com/stomita/heroku-buildpack-phantomjs.git



Related Topics



Leave a reply



Submit