【发布时间】:2019-11-09 17:50:00
【问题描述】:
我找到了一个应该在 lambda 上安装 phantomjs 的 4 year old project,但要么我做错了,要么自从创建了 repo 后事情发生了变化,它不再起作用。当我克隆和部署此存储库时,尝试运行 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'\n./phantomjs_lambda/phantomjs_linux-x86_64: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory\n",
"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)"
]
}
如果我使用最新的 linux 二进制文件而不是这个 repo 附带的二进制文件,我会收到一个不同但类似的错误,即缺少不同的 .so 文件。
对于上下文,我想安装 phantomjs 的原因是因为我想在我的 lambda 中使用节点 html-pdf library。
我在 Mac 上。
作为答案,我不希望通过这个特定的错误来发现下一个错误。我正在寻找一个能让我在 aws lambda 上工作的 phantomjs 的答案。如果有另一个节点“html 到 pdf”/“html 到 png”库不需要 phantomjs 即可工作并轻松在 AWS Lambda 上运行,那也是一个可以接受的解决方案。
【问题讨论】:
-
似乎使用 docker 可能是使用本机应用程序的最佳选择
-
你试过安装 phantom-prebuilt 吗?
-
@LuisEstevez 我在 Mac 上。我将如何以可以在 lambda linux 操作系统上运行的方式安装 phantom-prebuilt?
-
Phantom 相当老旧且不稳定。您可能尝试使用 puppet-chrome 代替,您可以查看 this guide。
-
感谢@Kane,但我认为这没有帮助,因为我的库被硬编码为使用 phantomjs。
标签: node.js amazon-web-services aws-lambda