exec and PATH on heroku with buildpacks
-
06-07-2021 - |
Pergunta
I use this buildpack in order to use casperjs on heroku.
Once my app created, I check my PATH
$ heroku config:get PATH
/usr/local/bin:/usr/bin:/bin:/app/vendor/phantomjs/bin:/app/vendor/casperjs/bin
OK, casperjs is in here!
--
Procfile
scraper: node scraper.js
scraper.js
var exec = require('child_process').exec;
exec('casperjs casper-script.js');
--
But when I launch the scraper process, it crashes with the following logs:
2012-10-09T02:23:38+00:00 heroku[scraper.1]: Starting process with command `node scraper.js`
2012-10-09T02:23:39+00:00 app[scraper.1]: bash: node: command not found
Why exec
does not find casperjs
which is in the PATH
?
PS: I tried with spawn
but no more luck...
[EDIT]: a testable gist here https://gist.github.com/3856317
Solução
Got it!
@vinayr: you were right, neither exec
nor casperjs
command was involved in this issue, it was node
which was the command not found
!
I thought installing a buildpack with phantomjs
and casperjs
(eg: heroku-buildpack-casperjs) would have kept node capabilities for my app, but it does not seem so.
To make it work (node+phantomjs+casperjs) I rather had to fork the heroku-buildpack-nodejs buildpack and add phantomjs
/casperjs
binaries to it, which I could have called: heroku-buildpack-nodejs-casperjs.
In other words, when using a custom buildpack, you have to include the node support yourself .