gpt4 book ai didi

找不到 Lambda wkhtmltopdf 命令

转载 作者:行者123 更新时间:2023-12-02 17:31:22 25 4
gpt4 key购买 nike

我想在 AWS Lambda 函数中将 html 转换为 pdf。有一个使用 wkhtmltopdf 的节点包。这是它的链接。

https://www.npmjs.com/package/wkhtmltopdf

但是当我运行我的代码时,出现以下错误。

Error: /bin/sh: wkhtmltopdf: command not found
at Socket.<anonymous> (/var/task/node_modules/wkhtmltopdf/index.js:79:17)
at Socket.g (events.js:180:16)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:427:10)
at emitReadable (_stream_readable.js:423:5)
at readableAddChunk (_stream_readable.js:166:9)
at Socket.Readable.push (_stream_readable.js:128:10)
at Pipe.onread (net.js:529:21)

有没有办法在 lambda 函数中安装“wkhtmltopdf”命令。

最佳答案

来自文档(https://www.npmjs.com/package/wkhtmltopdf):

First, you need to install the wkhtmltopdf command line tool on your system.

这是关于如何在 lambda 上安装文件的说明 https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/

Lambda’s built-in sandbox lets you safely run code written in any language, because Lambda doesn’t rely on the language runtime to provide isolation between functions. You get the same protections regardless of whether Lambda starts a process for you or whether you start it yourself, and regardless of the language in which it’s written. With that out of the way, let’s look at how easy it is:

Including your own executables is easy; just package them in the ZIP file you upload, and then reference them (including the relative path within the ZIP file you created) when you call them from Node.js or from other processes that you’ve previously started. Ensure that you include the following at the start of your function code:

关于找不到 Lambda wkhtmltopdf 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32813161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com