I have a Node.js/Express app on Heroku that uses PhantomJS. Everything runs fine locally (I'm using the PhantomJS - Node wrapper that I set up using NPM), but after deployed to production I get an error:
Express 500 Error: Cannot find module 'phantomjs'
I saw that I need to set up a Buildpack so I ran:
heroku config:add BUILDPACK_URL=https://github.com/stomita/heroku-buildpack-phantomjs.git git push heroku master
But still got the error. Also tried:
heroku config:set BUILDPACK_URL=https://github.com/stomita/heroku-buildpack-phantomjs.git git push heroku master
same result.
I think this BUILDPACK_URL is ignored.
Thoughts?
This was helpful. I'm moving my comment to an answer because this headless browsing took a lot of research and the details might help others.
Phantom names are confusing. Phantom JS is not a Node module and you can't download it directly from the npm registry. You can download the executable binary from phantomjs.org to install on your computer for local development and you can use the buildpack to install it on Heroku.
You can install these two popular Node wrappers for Phantom JS. These are not part of the core phantomjs.org project but they allow you to run that library from your Node app.
npm install phantomjs --save answered this question because the binary is stored in a directory the server knows to look for Phantom JS.I decided to use npm phantom for my Phantom wrapper and a custom buildpack to install the Phantom JS binary on Heroku. I don't like having Phantom JS 2.0 on Mac with Heroku running version 1.9.x. There are some issues so no Linux 2.0 is available yet.
Heroku made some minor syntax changes including optionally setting the order of the buildpacks using the buildpacks:add --index 1 flag with a numeric position. Run heroku buildpacks to see what you're using and in what order they get installed.
If you only have one buildpack use :set and buildpacks must be served over https so you can't just copy and paste old Phantom examples with http repos.
Heroku's Official Node buildpack
heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs
Unofficial Phantom JS buildpack (not the npm module)
heroku buildpacks:add https://github.com/stomita/heroku-buildpack-phantomjs
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