I found a 4 year old project that's supposed to install phantomjs on lambda, but either I'm doing something wrong, or things have changed since the repo was created and it no longer works. When I clone and deploy this repository, I get this error trying to run phantomjs:
{
"errorType": "Error",
"errorMessage": "write EPIPE",
"code": "EPIPE",
"stack": [
"Error: write EPIPE",
" at WriteWrap.afterWrite [as oncomplete] (net.js:779:14)"
],
"errno": "EPIPE",
"syscall": "write"
}
{
"errorType": "Error",
"errorMessage": "html-pdf: Received the exit code '127'
./phantomjs_lambda/phantomjs_linux-x86_64: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
",
"stack": [
"Error: html-pdf: Received the exit code '127'",
"./phantomjs_lambda/phantomjs_linux-x86_64: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory",
"",
" at ChildProcess.respond (/var/task/node_modules/html-pdf/lib/pdf.js:121:31)",
" at ChildProcess.emit (events.js:189:13)",
" at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)"
]
}
If I use the latest linux binary instead of the one that comes with this repo, I get a different but similar error about a different .so file missing.
For context, the reason I want to install phantomjs is because I want to use the node html-pdf library in my lambda.
I am on a Mac.
As an answer, I'm not looking to get past this specific error only to discover the next one. I'm looking for an answer that gets me a working phantomjs on aws lambda. If there is another node "html to pdf"/"html to png" library that doesn't require phantomjs to work and easily runs on AWS Lambda, that would be an acceptable solution, too.
See Question&Answers more detail:os